Reputation: 20232
I followed the instructions on the official PHPUnit page to install PHPUnit 6.
composer require --dev phpunit/phpunit ^6.0
However, If I go to the project folder and execute phpunit --version
then I get PHPUnit 3.7.21 by Sebastian Bergmann.
.
Why is PHPUnit 3.7.21 installed instead of PHPUnit 6?
Upvotes: 9
Views: 2912
Reputation: 2105
If you use XAMPP, why don't you update XAMPP version of global PHPUnit to desired.
1. Read this post, which quickly explains what to do: StackOverflow post
2. You can get phar file for version you need here: proper PHPUnit phar file
3. Which version of PHPUnit you need depends on your PHP version and you can identify it here: which phar file version you need
Just click on links: PHPUnit 9 - PHPUnit 8 - PHPUnit 7 - PHPUnit 6 - PHPUnit 5 - PHPUnit 4 and read description explaining which PHP version it works with.
Upvotes: 0
Reputation: 27295
You run your global PHPUnit version which is installed in another folder. To get the installed version you have to go to the vendor/bin
folder.
vendor/bin/phpunit --version
PHPUnit 6.0.8 by Sebastian Bergmann and contributors.
In newer versions you can run it with bin/phpunit
there should be the executable. When you need another PHP-Version then define it before php74 bin/phpunit
.
Upvotes: 7
Reputation: 626
I suppose you have xampp installed? It comes with PHPUnit 3.x.x preinstalled with PEAR which strangely can not be uninstalled with pear uninstall
. And since its config is in php root folder, that 3-ish version has priority when running phpunit command (even if you have phpunit installed globally) in CMD or PS. How to fix:
xampp/php
folder and delete two files phpunit
(with no extension) and phpunit.bat
. Usually it's enough to prevent older PHPUnit version from being run but let's be on the safer side:xampp/php/PEAR
dir and delete two folders PHPUnit
and PHPUnit2
.System and Security->System
and click "Advanced system settings" link on the left. This will open Advanced tab in System Properties window. Click "Environment Variables" button, then under System Variables select "Path" variable and click "Edit..." button. In the new window, click "New" button and type your path to vendor/bin
folder (if you already installed PHPUnit for your project there will be phpunit.bat file). By default for xamp it looks like this: C:\xampp\htdocs\yourprojectname\vendor\bin
.
phpunit --version
to see the that it's PHPUnit 6.x.x now. P.S. (If you want latest PHPUnit do not use ^6.0 in require string, since it will install v6.0.0, write it in composer.lock file that will never update PHPunit to the latest e.g. 6.2.1 version atm). Just use
composer require --dev phpunit/phpunit
to install the latest stable version for your project.
Upvotes: 23