Search code examples
integration-testingshopware6

Create order during integration testing


For my custom integration test, I need some dummy order (I want to update the tracking number later, as per my module).

Until now the best was I found is to copy

\Shopware\Core\Checkout\Test\Order\Listener\OrderStateChangeEventListenerTest::createOrder to my test class. Is there a more convenient method, with less copy & paste?


Solution

  • There is a trait for getting valid OrderData. Then you can modify the data to your needs and create it with the OrderRepository.

    You can find it here: src/Core/Checkout/Test/Customer/Rule/OrderFixture.php