sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.7k stars 2.2k forks source link

Warning message appears when calling TextUI TestRunner::run() #2078

Closed maikgreubel closed 8 years ago

maikgreubel commented 8 years ago

Using PHPUnit 5.2.5 I get multiple warning messages when calling PHPUnit_TextUI_TestRunner::run():

1.

[exec] Notice: Undefined variable: exit in D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 562
[exec]
[exec] Call Stack:
[exec]     0.0003     370352   1. {main}() D:\web\caribu-mvc\vendor\phpunit\phpunit\phpunit:0
[exec]     0.0067     889872   2. PHPUnit_TextUI_Command::main() D:\web\caribu-mvc\vendor\phpunit\phpunit\phpunit:47
[exec]     0.0067     893032   3. PHPUnit_TextUI_Command->run() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:109
[exec]     0.0067     893032   4. PHPUnit_TextUI_Command->handleArguments() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:120
[exec]     0.0137    1254848   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:674
[exec]     0.0137    1255432   6. PHPUnit_Util_Configuration->getTestSuite() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Configuration.php:819
[exec]     0.0190    1416624   7. PHPUnit_Framework_TestSuite->addTestFiles() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Configuration.php:908
[exec]     0.2045    3536400   8. PHPUnit_Framework_TestSuite->addTestFile() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Framework\TestSuite.php:409
[exec]     0.2046    3548744   9. PHPUnit_Util_Fileloader::checkAndLoad() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Framework\TestSuite.php:335
[exec]     0.2047    3548824  10. PHPUnit_Util_Fileloader::load() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
[exec]     0.2049    3581496  11. include_once('D:\web\caribu-mvc\tests\feature-test\RequestTest.php') D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Fileloader.php:56
[exec]     0.2049    3581496  12. Nkey\Caribu\Mvc\Tests\RequestTest::main() D:\web\caribu-mvc\tests\feature-test\RequestTest.php:68
[exec]     0.2080    3589720  13. PHPUnit_TextUI_TestRunner::run() D:\web\caribu-mvc\tests\feature-test\RequestTest.php:63
[exec]     0.2081    3590056  14. PHPUnit_TextUI_TestRunner->doRun() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:89

2.

[exec] Warning: Missing argument 3 for PHPUnit_TextUI_TestRunner::doRun(), called in D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 89 and defined in D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 148
[exec]
[exec] Call Stack:
[exec]     0.0003     370352   1. {main}() D:\web\caribu-mvc\vendor\phpunit\phpunit\phpunit:0
[exec]     0.0067     889872   2. PHPUnit_TextUI_Command::main() D:\web\caribu-mvc\vendor\phpunit\phpunit\phpunit:47
[exec]     0.0067     893032   3. PHPUnit_TextUI_Command->run() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:109
[exec]     0.0067     893032   4. PHPUnit_TextUI_Command->handleArguments() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:120
[exec]     0.0137    1254848   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\Command.php:674
[exec]     0.0137    1255432   6. PHPUnit_Util_Configuration->getTestSuite() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Configuration.php:819
[exec]     0.0190    1416624   7. PHPUnit_Framework_TestSuite->addTestFiles() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Configuration.php:908
[exec]     0.4086    3580416   8. PHPUnit_Framework_TestSuite->addTestFile() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Framework\TestSuite.php:409
[exec]     0.4087    3592760   9. PHPUnit_Util_Fileloader::checkAndLoad() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Framework\TestSuite.php:335
[exec]     0.4088    3592840  10. PHPUnit_Util_Fileloader::load() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
[exec]     0.4091    3627688  11. include_once('D:\web\caribu-mvc\tests\feature-test\ViewTest.php') D:\web\caribu-mvc\vendor\phpunit\phpunit\src\Util\Fileloader.php:56
[exec]     0.4095    3631672  12. Nkey\Caribu\Mvc\Tests\ViewTest::main() D:\web\caribu-mvc\tests\feature-test\ViewTest.php:88
[exec]     0.4119    3645032  13. PHPUnit_TextUI_TestRunner::run() D:\web\caribu-mvc\tests\feature-test\ViewTest.php:83
[exec]     0.4119    3645368  14. PHPUnit_TextUI_TestRunner->doRun() D:\web\caribu-mvc\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:89

No. 1 seems to be fixed if 2 is fixed first. Patch in line 86 => 97:

        if ($test instanceof PHPUnit_Framework_Test) {
            $aTestRunner = new self;

            return $aTestRunner->doRun(
                $test,
                $arguments,
                true
            );
        } else {
            throw new PHPUnit_Framework_Exception(
                'No test case or test suite found.'
            );
        }
sebastianbergmann commented 8 years ago

Quick question: how/why are you calling PHPUnit_TextUI_TestRunner::run()?

maikgreubel commented 8 years ago

It was just a test. I have a warning message in

piece/stagehand-testrunner/src/Runner/PHPUnitRunner.php

and just walked through code how to fix it properly.

tam5 commented 8 years ago

I am getting the same Missing argument 3 for PHPUnit_TextUI_TestRunner::doRun() warning for PHP 5.6 and hhvm on Travis, though PHP 7 passes.

Here is the full warning:

PHP Warning:  Missing argument 3 for PHPUnit_TextUI_TestRunner::doRun(), called in phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php on line 152 and defined in /home/travis/build/tam5/Arbitrage/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 148
PHP Stack trace:
PHP   1. {main}() /home/travis/.phpenv/versions/5.6.5/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.6.5/bin/phpunit:722
PHP   3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:104
PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:152

Then, my tests all pass, but i get the following:

PHP Fatal error:  Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.' in /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php:1341
Stack trace:
#0 /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php(1287): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php(1837): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php(2156): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php(2125): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(ErrorException))
#5 {main}
  thrown in /home/travis/build/tam5/Arbitrage/bootstrap/cache/compiled.php on line 1341

And then phpunit exists with 255.

Any ideas?

dochne commented 8 years ago

Make sure that if you're just running phpunit to run your tests that your globally scoped version is up to date to using phpunit --self-update.

I just had this problem and it seems to have been caused by my composer installed phpunit being a wildly different version to the globally installed one.

tam5 commented 8 years ago

Ah yes.

I was using travis to test on php 5.6, php 7.0, and hhvm. I definitely cannot say I understand why I got this problem, for starters my tests were in fact being run by PHPUnit 5.2.9 (and all passed), plus I was not getting any errors on the php 7.0 build.

However, based on your suggestion @Dolondro, it turned out that indeed while my tests were seemingly being run by PHPUnit 5.2.9, the global version of PHPUnit seemed to be 4.5.0. So based on your suggestion I changed the script in my .travis.yml from:

script: phpunit
to:
script: vendor/phpunit/phpunit/phpunit

and I got greens on all builds.

Thus, this seems to be a Travis issue and not really a PHPUnit issue.

sebastianbergmann commented 8 years ago

Can this be closed?

tam5 commented 8 years ago

good w me