-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Hello,
I've been working on a custom PHPStan rule for my team to validate the correct usage of test classes. This rule checks if a test class is using any methods from its immediate parent class. If not, it suggests inheriting from a more appropriate parent class.
Specifically, it validates test classes that extend:
- Liip\FunctionalTestBundle\Test\WebTestCase
- Symfony\Bundle\FrameworkBundle\Test\WebTestCase
- Symfony\Bundle\FrameworkBundle\Test\KernelTestCase
For example, if a test class extends Symfony\Bundle\FrameworkBundle\Test\KernelTestCase but doesn't use any of its methods, the rule would report an error and suggest trying PHPUnit\Framework\TestCase instead.
We implemented this rule because in our large team, many developers were writing tests that weren't optimally structured, leading to slower pipeline execution. This rule helps ensure tests are written using the most efficient base class.
If this idea aligns with the project's goals, I'd be happy to refine the code of my custom rule and submit a pull request to phpstan-symfony, potentially for the 2.1.0 release.
Thank you for your consideration.