6

A very good thing about Magento 2 is that we put together all files inside the module itself. Layout XML, Templates, Less/Sass, Blocks, Models, Helpers, API, SQL scripts and everything. It's important because when we enable, disable or even delete the module everything lays on a single directory.

However, when I add a @magentoDataFixture for an integration test, it says it should be placed on dev/tests/integration/testsuite directory, and not on the module itself. The more directories, the more difficult to maintain. It looks like M1 with app and skin directories where files became very far away from each other, in terms of tree directory.

Example:

/**
 * @magentoDataFixture MyNamespace/MyModule/_files/create_some_data_here.php
 */
class CustomIntegrationTestTest extends AbstractController
{

Magento will look up on the directory: dev/tests/integration/testsuite/MyNamespace/MyModule/_files/create_some_data_here.php

and not somewhere like this: app/code/MyNamespace/MyModule/Test/....../_files/create_some_data_here.php

Can @magentoDataFixture files be inside the module itself and not on default directory dev/tests/integration/testsuite?

2
1

Yes it can. You can pass a relative path starting from dev/tests/integration/testsuite and Magento will pickup the fixture.

If you have the fixture app/code/MyNamespace/MyModule/Test/_files/create_some_data_here.php you can use the following @magentoDataFixture annotation:

/**
 * @magentoDataFixture ../../../../app/code/MyNamespace/MyModule/Test/_files/create_some_data_here.php
 */
public function testSomething() {}

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.