Hi Sebastian,
| Q | A |
|---------------------|----------|
| PHPUnit version | 8.2.8 |
| PHP version | 7.2.14 |
| Laravel Version | 6.0.4 |
| Installation method | Composer |
When running phpunit I get Notice: Undefined index: warnings in C:\wamp64\www\wbd\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 334 warning message.
Getting warning message in the console when running phpunit command. The test are running, but this warning message showing every time. Tried with --filter=xxx with the same result.
Run phpunit.
Not to show this warning
I've dig down to C:\wamp64\www\wbd\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 334 which is
foreach ($arguments['warnings'] as $warning) {
$this->writeMessage('Warning', $warning);
}
I've wrapped this foreach in if (isset($arguments['warnings'])) { and when I run phpunit in my console the warning message no longer showing and the tests are running too.
This is the full message from console:
`PHPUnit 8.5.0 by Sebastian Bergmann and contributors.
Notice: Undefined index: warnings in C:\wamp64\www\wbd\vendorphpunitphpunit\src\TextUI\TestRunner.php on line 334
Call Stack:
0.0004 400464 1. {main}() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunitphpunit:0
0.0165 1203216 2. PHPUnit\TextUI\Command::main() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunitphpunit:61
0.0166 1212008 3. PHPUnit\TextUI\Command->run() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunit\src\TextUI\Command.php:160
0.2192 8506648 4. PHPUnit\TextUI\TestRunner->doRun() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunit\src\TextUI\Command.php:201
Warning: Invalid argument supplied for foreach() in C:\wamp64\www\wbd\vendorphpunitphpunit\src\TextUI\TestRunner.php on line 334
Call Stack:
0.0004 400464 1. {main}() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunitphpunit:0
0.0165 1203216 2. PHPUnit\TextUI\Command::main() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunitphpunit:61
0.0166 1212008 3. PHPUnit\TextUI\Command->run() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunit\src\TextUI\Command.php:160
0.2192 8506648 4. PHPUnit\TextUI\TestRunner->doRun() C:\Users\afeher\AppData\Roaming\Composer\vendorphpunitphpunit\src\TextUI\Command.php:201
. 1 / 1 (100%)
Time: 13.19 seconds, Memory: 48.00 MB
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... done [5.06 seconds]`
Thank you for your report.
Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.
Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.
Also note what I wrote in https://github.com/sebastianbergmann/phpunit/pull/3977#issuecomment-562815411 as I think that this is the same issue.
Thank you for your report.
Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.
Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.
Hi Sebastian,
When I run phpunit this warning shows. This is nothing to do with any of my test cases.
I do not get the warning with any of my test suites. This makes me think that it has something to do with the tests being run. I will investigate this next week.
@WBDC can you check your actual phpunit version with phpunit --version ?
It is possible that your composer global requirement is set to 7.x
what happens if you run C:\wamp64\www\wbd\vendor\bin\phpunit
if this fixes the problem, i'd suggest opening
C:\Users\afeher\AppData\Roaming\Composer\composer.json
and updating the phpunit major version accordingly.
@tvercruysse that worked for me. Updating the global phpunit version got rid of the warnings. Thanks 馃憤
@tvercruysse The phpunit in composer is "phpunit/phpunit": "^8.0"
Just by typing phpunit gives PHPUnit 8.5.0 by Sebastian Bergmann and contributors (image below)


The global composer for the phpunit was ^8.2. The warning not showing anymore after doing a global composer update.
Many thanks for the help! Its silly mistake, but learned something today. Thank you!
@sebastianbergmann Could you please close this ticket as it is resolved. Maybe worth to put this in the documentation? Even if this wasn't phpunit fault, (purely my mistake), but I'm sure others would find it useful.
Thanks for looking into it though!
I had the same problem, it was I wan running the phpunit script of the Symfony bridge I think in ./bin instead of using: ./vendor/bin/phpunit.
Most helpful comment
@WBDC can you check your actual phpunit version with
phpunit --version?It is possible that your composer global requirement is set to
7.xwhat happens if you run
C:\wamp64\www\wbd\vendor\bin\phpunitif this fixes the problem, i'd suggest opening
C:\Users\afeher\AppData\Roaming\Composer\composer.jsonand updating the phpunit major version accordingly.