tddwizard / magento2-fixtures

Fixture library for Magento 2 integration tests by @schmengler (@integer-net)

Home Page:http://tddwizard.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OrderBuilder fails after CartBuilder

tim-bezhashvyly opened this issue · comments

If I'm using an order builder right after the cart builder I'm getting the following error:

Magento\Framework\Validator\Exception : Please check the shipping address information. Provided customer ID "0" isn't related to current customer address.
 /path/to/vendor/magento/module-quote/Model/QuoteValidator.php:109
 /path/to/vendor/magento/module-quote/Model/SubmitQuoteValidator.php:52
 /path/to/vendor/magento/module-quote/Model/QuoteManagement.php:529
 /path/to/vendor/magento/module-quote/Model/QuoteManagement.php:483
 /path/to/vendor/magento/framework/Interception/Interceptor.php:58
 /path/to/vendor/magento/framework/Interception/Interceptor.php:138
 /path/to/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php:54
 /path/to/vendor/magento/framework/Interception/Interceptor.php:135
 /path/to/vendor/magento/framework/Interception/Interceptor.php:153
 /path/to/generated/code/Magento/Quote/Model/QuoteManagement/Interceptor.php:32
 /path/to/vendor/tddwizard/magento2-fixtures/src/Checkout/CustomerCheckout.php:173
 /path/to/vendor/tddwizard/magento2-fixtures/src/Sales/OrderBuilder.php:146
 /path/to/app/code/Aescripts/RequiredPurchase/Test/Integration/Observer/DummyTest.php:16

Here is the reproducible code minimum:

<?php

declare(strict_types=1);

namespace Vendor\Module\Test\Integration\Observer;

use PHPUnit\Framework\TestCase;
use TddWizard\Fixtures\Checkout\CartBuilder;
use TddWizard\Fixtures\Sales\OrderBuilder;

class DummyTest extends TestCase
{
    public function testOrderCreation(): void
    {
        CartBuilder::forCurrentSession()->build();
        OrderBuilder::anOrder()->build();
    }
}

The execution command is following:

/opt/homebrew/Cellar/php/8.2.4/bin/php /path/to/vendor/phpunit/phpunit/phpunit --configuration /path/to/dev/tests/integration/phpunit.xml --filter Vendor\Module\Test\Integration\Observer\DummyTest --test-suffix DummyTest.php /path/to/app/code/Aescripts/RequiredPurchase/Test/Integration/Observer --teamcity