magento-coding-standard
magento-coding-standard copied to clipboard
Unit Tests: Cross-module inheritance forbidden
trafficstars
Rule
Inheritance from namespace other than \PHPUnit\... and the same that module is in is forbidden
Reason
TLDR: Avoid unnecessary coupling between modules.
While working with Unit Tests migration for Magento Commerce / B2B, we have faced multiple weird types of inheritance introduced - eg. Unit Test completely unrelated to Magento Catalog, inherited Unit Test from Magento Catalog to get the setUp executed and mocks created (that is the only reason). Changes introduced to Magento Catalog caused failures of Commerce modules Unit Tests. That is unacceptable, as the unit of responsibility for Magento Commerce module hasn't changed and if the mocks were independent - the test would still pass.
Implementation
CC
@slavvka @dmytro-ch