Closed toonvandenbos closed 5 months ago
I am getting the following error when tried to re-produce.
PHP Fatal error: Class App\Library\FakeObject contains 1 abstract method and must therefore be declared abstract or implement the remaining methods
This is fixed on Pest 2.33 - it will be released tomorrow morning.
What Happened
While developing a new Laravel Package I stumbled across an unexpected "silent" failure in Pest's execution.
In one of my test files, I had a specific test that needed to instantiate a "Fixture" class as such:
This
Whitecube\NewPackage\Tests\Fixtures\FakeResolver
class is implementing an interface my package requires, but at some point I forgot to implement one of its methods. I would expect Pest to tell me about it and show the exception as it does for any other problem encountered during the tests' execution, but instead it does nothing and stops any further testing execution.To my knowledge, any other exception or error has an appropriate output. For instance, I tried to instantiate an undefined class inside said test, resulting in the expected exception output. It seems to me there only is a weird behavior when an interface's method is not implemented in a concrete class.
How to Reproduce
mkdir foobar && cd foobar && mkdir src/ && touch src/FooBar.php
pestphp/pest
as described in the docs:composer require pestphp/pest --dev --with-all-dependencies && ./vendor/bin/pest --init
Create an interface inside the package's
src
directory:Create a new fixture class implementing the freshly created interface inside the package's
tests/Fixtures
directory, but do not implement the interface'smethodToImplement
method:composer.json
file for the classes located inside/tests
, then runcomposer dumpautoload
:Write 3 dummy tests and let the middle one create a new instance of
Whitecube\Foobar\Tests\Fixtures\FakeObject
:Now, run the tests using
./vendor/bin/pest
. In my case, nothing is displayed in the output:In order to demonstrate that everything is working as expected, all 3 tests are executed when commenting the
new FakeObject;
line (or when resolving the issue by implementing the missing method insideFakeObject
, of course):For more convenience, I published a sample repository containing the case above.
Sample Repository
https://github.com/whitecube/foobar-pestphp-issue-sample
Pest Version
2.31.0
PHP Version
8.1.14
Operation System
macOS
Notes
No response