tddwizard / magento2-fixtures

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

Cannot create Order with given customer #89

Open tim-bezhashvyly opened 1 year ago

tim-bezhashvyly commented 1 year ago

The code below is expected to create an order via OrderBuilder with specific customer:

        $customerBuilder = CustomerBuilder::aCustomer()->withAddresses(
            AddressBuilder::anAddress()->asDefaultBilling(),
            AddressBuilder::anAddress()->asDefaultShipping()
        );

        $customerFixture = new CustomerFixture($customerBuilder->build());

        $order = OrderBuilder::anOrder()
            ->withCustomer($customerBuilder)
            ->withProducts(
                ProductBuilder::aVirtualProduct()->withSku(RequiredPurchase::FLOATING_SERVER_SKU)
            )
            ->build();

        echo $order->getRealOrderId() . "\n";
        echo $order->getCustomerId() . "\n";
        echo $customerFixture->getId();

The output is the following:

000000064
656
655

As you can see the OrderBuilder has created a new customer.