ho-nl / magento2-ReachDigital_TestFramework

Faster drop-in replacement for Magento's integration test.
MIT License
76 stars 13 forks source link

LocalizedException: The configuration file has changed when using TestCase\AbstractController #26

Open elburro1887 opened 3 years ago

elburro1887 commented 3 years ago

My test looks like this:

class ProductTest extends \Magento\TestFramework\TestCase\AbstractController
{

    public static function loadFixture()
    {
        include __DIR__ . '/../_files/categories.php';
    }

    /**
     * @magentoDbIsolation enabled
     * @magentoAppIsolation enabled
     * @magentoDataFixture loadFixture
     */
    public function testCategory()
    {
        $this->dispatch('catalog/category/view/id/3');
        $this->assertContains('Category 1', $this->getResponse()->getBody());
    }

}

Then when I run the integration test with the plugin, the call to $this->dispatch() leads to this error:

Magento\Framework\Exception\LocalizedException: The configuration file has changed. Run the "app:config:import" or the "setup:upgrade" command to synchronize the configuration.

magento/vendor/magento/module-deploy/Model/Plugin/ConfigChangeDetector.php:50
magento/vendor/magento/framework/Interception/Interceptor.php:121
magento/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69
magento/vendor/magento/framework/Interception/Interceptor.php:135
magento/vendor/magento/framework/Interception/Interceptor.php:153
magento/generated/code/Magento/Framework/App/FrontController/Interceptor.php:26
magento/vendor/magento/framework/App/Http.php:137
magento/generated/code/Magento/Framework/App/Http/Interceptor.php:24
magento/dev/tests/integration/framework/Magento/TestFramework/Application.php:449
magento/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php:117
magento/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php:116
magento/app/code/XYX/Module/Test/Integration/Controller/ProductTest.php:58

Maybe this is related to using/extending AbstractController?

EDIT: So when I run a test that uses extend \PHPUnit\Framework\TestCase it works.

Does anyone know what I can do to be able to use Controller Test cases?

jissereitsma commented 3 years ago

This sounds pretty similar to the following topic: https://magento.stackexchange.com/questions/323506/getting-the-configuration-file-has-changed-run-the-appconfigimport-d This would suggest the integration test database is in an inconsistent state, perhaps because of other modules being present that break the setup.

Could you test for the regular Integration Tests setup (so, of the Magento core) to see if the problem occurs there as well? Perhaps the issue you are having is not related to the Reach Digital Test Framework (which would justify posting here) but related to the specific modules you have installed in the instance where you run the tests.