pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: Some Architecture tests works incorrectly with BypassFinals enabled

Open Perf opened this issue 1 year ago • 0 comments

What Happened

Together with installed package nunomaduro/mock-final-classes, which uses dg/bypass-finals under the hood, execution of the following test produces false result.

It doesn't matter if the class defined as final or not, the test always passes. The same situation happens when testing that class should not be readonly, due to the same reason.

test('entity classes should not be final')
    ->expect('App\Domain\Entity')
    ->classes()
    ->not->toBeFinal();

How to Reproduce

  • Install package nunomaduro/mock-final-classes
  • create Architecture test that tests some class that it's not final
  • run the test
  • it will always pass, disregarding if the class is final or not

Sample Repository

No response

Pest Version

2.34.0

PHP Version

8.3.2

Operation System

Linux

Notes

Probably it should be somehow possible to disable dg/bypass-finals when running architecture tests.

Perf avatar Feb 27 '24 17:02 Perf