I tried using PHPUnit 9 but it does not support the latest version of PHP above 8.0 I get the following error
Fatal error: Uncaught error: Call to undefined function each() in C:\xampp\php\pear\PHPUnit\Util\Getopt.php:80 Stack trace: #0 C:\xampp\php\pear \PHPUnit \TextUI\Command.php(242): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array) #1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(138) : PHPUnit_TextUI_Command ->handleArguments(Array) #2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true) #3 C:\xampp\php\ phpunit(46): PHPUnit_TextUI_Command ::main() #4 {main} throws
in C:\xampp\php\pear\PHPUnit\Util\Getopt.php on line 80
Make sure you are not using an older version of PHPUnit to install the global package.
Check this answer to find globally installed packages.
Maybe you are calling global instead of project.
If you can remove it using
I guess your environment
PATH
variable contains the global Composer folder, sophpunit
will call that by default.Otherwise, use
./vendor/bin/phpunit
(from directoryC:\xampp\htdocs\test
) to call the specific version you installed in your project.