我是phpUnit的新手。我通过作曲家安装了它。我的作曲家.json如下:
"require": {
"php": ">=5.5.9",
"symfony/symfony": "^2.8",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"doctrine/mongodb-odm": "~1.0",
"doctrine/mongodb-odm-bundle": "~3.0",
"nicmart/tree": "~0.2",
"jms/serializer-bundle": "^1.1",
"simple-bus/symfony-bridge": "^4.1",
"phpunit/phpunit":">=4.2",
"codeception/codeception": "*",
"nicolopignatelli/valueobjects": "^4.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^2.7"
}
在composer update
期间,我收到了
- 安装 phpunit/phpunit (5.2.9)
我在我的供应商中看到phpunit目录。
现在,在简单地尝试输出phpunit版本(或尝试开始测试)时,我收到以下错误消息:
me@myMachine:root/path/of/symfony$ phpunit -v
The program 'phpunit' is currently not installed. To run 'phpunit' please ask your administrator to install the package 'phpunit'
在 bash 中创建有什么快捷方式吗?
更新
就像当前 2 个答案所建议的那样,我试图运行me@myMachine:root/path/of/symfony$ ./vendor/bin/phpunit -v
但它返回一个permission denied
异常,尽管当前用户 (me@myMachine) 是文件所有者。
此外,me@myMachine:root/path/of/symfony$ ls -l ./vendor/bin
回报
-rw-rw-rw- 1 me me 612 Mar 1 09:52 codecept
-rw-rw-rw- 1 me me 603 Jan 28 13:50 doctrine
-rw-rw-rw- 1 me me 609 Jan 28 13:50 doctrine-dbal
-rw-rw-rw- 1 me me 607 Jan 28 13:50 doctrine.php
-rw-rw-rw- 1 me me 608 Feb 24 19:20 geotools
-rw-rw-rw- 1 me me 603 Mar 1 09:52 phpunit
-rw-rw-rw- 1 me me 978 Jan 20 12:15 security-checker
如果尝试chmod -vR u+x ./vendor/bin
它按预期返回
mode of ‘bin/’ changed from 0777 (rwxrwxrwx) to 0766 (rwxrw-rw-)
mode of ‘bin/phpunit’ changed from 0666 (rw-rw-rw-) to 0766 (rwxrw-rw-)
但me@myMachine:root/path/of/symfony$ ls -l ./vendor/bin
又回来了
-rw-rw-rw- 1 me me 612 Mar 1 09:52 codecept
-rw-rw-rw- 1 me me 603 Jan 28 13:50 doctrine
-rw-rw-rw- 1 me me 609 Jan 28 13:50 doctrine-dbal
-rw-rw-rw- 1 me me 607 Jan 28 13:50 doctrine.php
-rw-rw-rw- 1 me me 608 Feb 24 19:20 geotools
-rw-rw-rw- 1 me me 603 Mar 1 09:52 phpunit
-rw-rw-rw- 1 me me 978 Jan 20 12:15 security-checker
就像没有考虑 CHMOD 一样。
更新 2
显然,这个问题与流浪汉有关。
我在 2.8 和 3.0 版本中完全重新安装了 symfony,问题仍然存在。
我发现了这个类似的问题,因此选择全局composer global require phpunit/phpunit
安装 phpUnit,然后再次运行phpunit -v
。这次,找到了命令,但我收到以下错误
me@myMachine:/path/to/symfony/root$ phpunit -v
PHPUnit 4.8.23 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.14-1+deb.sury.org~trusty+1
Configuration: /var/www/public/symfony/sgv3/sgv3/phpunit.xml.dist
. 1 / 1 (100%)
Time: 6.86 seconds, Memory: 27.75Mb
PHP Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 185
如果您通过 Composer 安装 PHPUnit,那么它的二进制文件将位于 vendor/bin/phpunit
。
调用项目供应商 bin 目录中的特定二进制文件,例如
bin/phpunit -h