I have setup integration tests for app/code that was working fine.
Now I have a module that adds some product attributes in a setup script, it doesn't have any tests but it is part of the project. When running integration tests it will fail with the exception: Wrong entity ID
This happens when the setup does this:
$eavSetup->addAttribute(Product::ENTITY, $attributeCode, $attributeDefinition);
The error happens because table eav_entity_type is empty for some reason. what am I missing something here?
Best Answer
If you have
<const name="TESTS_CLEANUP" value="enabled"/>
in yourphpunit.xml
(which is the default), Magento starts the test suite with an empty database and runs all setup scripts.In your case, it looks like the setup script of the custom module runs before the one of
Magento_Catalog
which adds the product type toeav_entity_type
.To overcome this, add
Magento_Catalog
as a module dependency.