首页 > 解决方案 > Does a global phpunit check for local version?

问题描述

I have installed phpunit globally (v7.1.4). My project uses phpunit ^6 as defined in composer.json.

If I run $ phpunit --version within the project dir I see:

$ phpunit --version
PHPUnit 7.1.4 by Sebastian Bergmann and contributors.

But if I run my tests another version is used:

$ phpunit
PHPUnit 6.5.7 by Sebastian Bergmann and contributors.

.............                                                     13 / 13 (100%)

Time: 839 ms, Memory: 10.00MB

OK (13 tests, 16 assertions)

My question is: Does phpunit check for a locally installed version and uses this for the project or is my system acting weired?

标签: phpunit

解决方案


No, PHPUnit does nothing of the sort.

You have a project-local version of PHPUnit installed via Composer but do not invoke it via ./vendor/bin/phpunit. Thus the globally installed PHPUnit is used.


推荐阅读