dmaicher / doctrine-test-bundle

Symfony bundle to isolate your app's doctrine database tests and improve the test performance
MIT License
1.08k stars 61 forks source link

Fatal error: Interface 'PHPUnit\Runner\AfterTestHook' not found #93

Closed truckee closed 5 years ago

truckee commented 5 years ago

Attempting to run tests in a Symfony 4.3 application in the Netbeans IDE results in the following:

"C:\Users\George\AppData\Roaming\Composer\vendor\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\George\AppData\Local\Temp\nb-phpunit-log.xml" "--configuration" "G:\Documents\workspace\cfwn\phpunit.xml.dist" "C:\Program Files\Netbeans-11.1-dev\netbeans\php\phpunit\NetBeansSuite.php"

Fatal error: Interface 'PHPUnit\Runner\AfterTestHook' not found in G:\Documents\workspace\cfwn\vendor\dama\doctrine-test-bundle\src\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension.php on line 11
Done.

I strongly suspect the error is due to Netbeans because I can successfully run tests at the command line. I'm just hoping you have some idea on how to test in Netbeans. Its version is the latest development build as of this writing. symfony/phpunit-bridge is 4.3.5; PHPUnit is 7.5.16.

Interestingly, adding a project dependency to phpunit (as suggested by them) results in a series of phpunit errors. I've since removed the dependency, leaving a big mess to clean up. :

Notice: Undefined index: arguments in G:\Documents\workspace\cfwn\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1058

Warning: count(): Parameter must be an array or an object that implements Countable in G:\Documents\workspace\cfwn\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1058
PHPUnit 8.4.0 by Sebastian Bergmann and contributors.

Fatal error: Uncaught Error: Call to undefined method PHPUnit\Util\Configuration::hasValidationErrors() in G:\Documents\workspace\cfwn\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:348
Stack trace:
#0 C:\Users\George\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(NetBeansSuite), Array, true)
#1 C:\Users\George\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(151): PHPUnit\TextUI\Command->run(Array, true)
#2 C:\Users\George\AppData\Roaming\Composer\vendor\phpunit\phpunit\phpunit(53): PHPUnit\TextUI\Command::main()
#3 {main}
  thrown in G:\Documents\workspace\cfwn\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 348

Close this if you believe it's S(omebody) E(lse's) P(roblem).

dmaicher commented 5 years ago

Sorry but indeed I will close this because that's not an issue with the bundle itself. No idea what Netbeans is doing there.

This question is more suitable for StackOverflow :wink:

truckee commented 5 years ago

Well it isn't Netbeans that's at fault. I started a new project in an effort to create a procedure for reproducing the issue but the error does not appear. Only difference noted between original project and new one is the former showed phpunit as 7.5.16 and the latter as 7.5.17.

Still SEP though.

Edit: Removed and reinstalled global PHPUnit (from 7.1 to 8.4) and all is well in original project. Somebody else === PHPUnit.

Toilal commented 4 years ago

@dmaicher This interface doesn't exists before PHPUnit 7.5.

Please reopen the issue as it's not only a bug with Netbeans. On PHPUnit <7.5, the rollback method is not invoked at all.

dmaicher commented 4 years ago

@Toilal indeed you are right.

I adjusted the readme for this. So please update to PHPUnit 7.5+ or use the listener instead of the extension. Like


    <listeners>
        <listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitListener" />
    </listeners>