2

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?

  • You're looking for "fixtures" – Robbie Averill May 24 '16 at 0:10
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.