Skip to content

Unit Tests: Cross-module inheritance forbidden #182

Open
@lbajsarowicz

Description

@lbajsarowicz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalNew rule proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions