tddwizard / magento2-fixtures

Fixture library for Magento 2 integration tests by @schmengler (@integer-net)
http://tddwizard.com/
MIT License
141 stars 28 forks source link

Missing the ability to generate a masked ID for a quote #91

Open Skullsneeze opened 6 months ago

Skullsneeze commented 6 months ago

Normally when generating a cart for a guest user a masked quote ID is returned instead of the quote entity ID. You can work around this by creating your own mask ID record using the Magento\Quote\Model\QuoteIdMaskFactory class, but it might be nice to add this to the CartBuilder?

This could be done in 2 ways. Either by adding another withMaskedId method. For example:

$cart = CartBuilder::forCurrentSession()
            ->withSimpleProduct(
                $this->productFixture->getSku()
            )
            ->withMaskedId()
            ->build();

Or perhaps with an isGuestCart method?

$cart = CartBuilder::forCurrentSession()
            ->withSimpleProduct(
                $this->productFixture->getSku()
            )
            ->isGuestCart()
            ->build();

I'm not sure which solution would be preferred, or if this is something that would even be considered as a valuable addition. However, if it is I can create a PR with the needed changes.