amitsolanki24_'s avatar

Getting error while running Test Case

I'm using Laravel Framework 10.17.1

php artisan test

   WARN  Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

   PASS  Tests\Unit\ExampleTest
  ✓ that true is true
  Call to undefined method PHPUnit\TestRunner\TestResult\TestResult::numberOfTests()

0 likes
12 replies
tykus's avatar

Just a PHPUnit configuration change whenever we changed to PHPUnit v10, which you can resolve using the following command:

vendor/bin/phpunit --migrate-configuration

And in addition:

Furthermore, if you wish to use PHPUnit 10, you should delete the processUncoveredFiles attribute from the <coverage> section of your application's phpunit.xml configuration file. Then, update the following dependencies in your application's composer.json file:

nunomaduro/collision to ^7.0

phpunit/phpunit to ^10.0

https://laravel.com/docs/10.x/upgrade

1 like
amitsolanki24_'s avatar

@tykus when I run vendor command its giving error

vendor is not recognized as an internal or external command
tykus's avatar

@amitsolanki24_ try prefixing with the current directory (from your project root):

./vendor/bin/phpunit --migrate-configuration
amitsolanki24_'s avatar

@tykus

I'm already in my project directory

vendor/bin/phpunit --migrate-configuration

'vendor' is not recognized as an internal or external command, operable program or batch file.

while running this php artisan vendor/bin/phpunit --migrate-configuration getting error

 ERROR  Command "vendor/bin/phpunit" is not defined.

I'm running like this

Dell@DELL-NOTEBOOK c:\xampp\htdocs\testing
# vendor/bin/phpunit --migrate-configuration
'vendor' is not recognized as an internal or external command,
operable program or batch file.


Dell@DELL-NOTEBOOK c:\xampp\htdocs\testing
# php artisan vendor/bin/phpunit --migrate-configuration
   ERROR  Command "vendor/bin/phpunit" is not defined.

tykus's avatar

@amitsolanki24_ Windows does not like forward slashes; using quotes might work; can't test

"./vendor/bin/phpunit --migrate-configuration"
1 like
martinbean's avatar

If only the message gave you instructions on what to do…

2 likes
amitsolanki24_'s avatar

@martinbean I ran this command but getting error.

php artisan --migrate-configuration

And there is no command like --migrate-configuration

martinbean's avatar
Level 80

@amitsolanki24_ Because you’re meant to use that option with PHPUnit:

vendor/bin/phpunit --migrate-configuration

This will copy your existing phpunit.xml file to phpunit.xml.bak, and create a new phpunit.xml file with the updated configuration.

1 like
tykus's avatar

@amitsolanki24_ because you're on Windows and it doesn't like forward slashes. Did my earlier message solve your issue?

arthvrian's avatar

@amitsolanki24_ if you have PHP installed and added to Windows PATH variable, run this (from your project folder):

php vendor/bin/phpunit --migrate-configuration

otherwise you must set the full path for php.exe like this

c:\php\php.exe vendor/bin/phpunit --migrate-configuration

1 like

Please or to participate in this conversation.