I am currently writing my first unit test. The basis of the test is I get all of the order information along with the items and create a JSON object from it. Is there a way to create dummy items and orders with preset data?
1 Answer
You should distinguish between unit and integration tests.
Unit Test
In a unit test the class under test should get the order data from a collaborator that you can inject as a mock, for example the OrderRepositoryInterface
.
Integration Test
If you want to get test order data from the database, consider writing an integration test instead of a unit test.
Then use the @magentoDataFixture Magento/Sales/_files/order.php
annotation to create a test order fixture for the test.