Why does phpunit work not to run vendor / bin / phpunit?

I have a strange problem when I run

$ phpunit

I get

Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 185

Call Stack:
    0.0009     231392   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
    0.0065     743872   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
    0.0066     744512   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:106
    1.1720    6818904   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:155
    1.4597   16188088   5. PHPUnit_TextUI_ResultPrinter->printResult() /vagrant/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:446

However, when I run

$ ./vendor/bin/phpunit 

works as expected and runs my tests.

Maybe I have another program or something that uses the phpunit alias or something else?

How can I debug this? Any ideas?

+4
source share
4 answers

Suppose you installed Laravel phpunitfrom the composer.jsoncurrent application.

Run this: vendor/phpunit/phpunit/phpunit

Because global may be an incompatible version of phpunit. Which is called and executed in the current package.

+3
source

On Windows, I have an incompatible version installed globally.

, "phpunit.bat" :

"vendor/bin/phpunit"

phpunit .

0

Windows .

/:

set phpunit=vendor/bin/phpunit

Laravel PhpStorm, , PhpStorm, .

0

/vendor/bin ?

~/.bashrc:

PATH="$PATH:/path/to/vendor/bin"

/vendor/bin/ , , , phpunit, - , - .

To fix this, add vendor/binto the beginning of your path in ~/.bashrc:

PATH="/path/to/vendor/bin:$PATH"

Then log out and start source ~/.bashrcor run source ~/.bashrc, and then the system should find it /vendor/bin/phpunitat startup phpunit.

0
source

Source: https://habr.com/ru/post/1624051/


All Articles