我以前让PHPUnit使用我的Zend Framework 1.11没有问题,但没有使用它。
我现在已经在Quick Start网站上运行了Zend Framewoprk 2,但我根本无法使PHPUnit工作。
我在Stackoverflow上搜索了很多与此相关的问题,并尝试重新安装和路径更改到php.ini但没有成功。
我还检查过我的PEAR安装工作正常,但是当我尝试“phpunit --version”时错误是一样的
PHP Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
PHP Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/johnadmin/pear/share/pear/PEAR:/Users/johnadmin/pear/share/pear:/usr/bin/phpunit:/Users/johnadmin/pear/share/pear/PHPUnit:/usr/bin/phpunit:/Users/johnadmin/pear/bin/pear') in /usr/bin/phpunit on line 43
Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/johnadmin/pear/share/pear/PEAR:/Users/johnadmin/pear/share/pear:/usr/bin/phpunit:/Users/johnadmin/pear/share/pear/PHPUnit:/usr/bin/phpunit:/Users/johnadmin/pear/bin/pear') in /usr/bin/phpunit on line 43
尝试重新安装phpunit导致我被告知phpunit已经安装并且其版本是最新的。
$ sudo pear install phpunit/PHPUnit
phpunit/PHPUnit is already installed and is the same as the released version 3.7.10
install failed
尝试卸载失败,因为phpunit是其他项目/应用程序的依赖。
无论如何,我可以解决这个问题,还是完全删除它并重新安装新的?
我的php.ini中的include_path是:
include_path=".:/Users/johnadmin/pear/share/pear/PEAR:/Users/johnadmin/pear/share/pear:/usr/bin/phpunit:/Users/johnadmin/pear/share/pear/PHPUnit:/usr/bin/phpunit:/Users/johnadmin/pear/bin/pear"
附加信息,如果相关:
> which phpunit
/usr/bin/phpunit
> which pear
/Users/johnadmin/pear/bin/pear
> which php
/usr/bin/php
Autoload.php位于
/Users/johnadmin/pear/share/pear/PHPUnit
此外,文件夹'/ usr / lib / php /'存在,但PHPUnit目录不在其下,它位于 / Users / johnadmin / pear / share / pear / PHPUnit
bash_profile内容/路径
PATH=$PATH:/usr/local/Cellar/imagick/3.0.1:/usr/local/sbin:/Users/johnadmin/pear/share/pear:$
##
# Your previous /Users/johnadmin/.bash_profile file was backed up as /Users/johnadmin/.bash_$
##
# MacPorts Installer addition on 2012-04-17_at_08:37:29: adding an appropriate PATH variable$
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
##
# Your previous /Users/johnadmin/.bash_profile file was backed up as /Users/johnadmin/.bash_$
##
# MacPorts Installer addition on 2012-10-09_at_16:09:32: adding an appropriate PATH variable$
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
##
# Your previous /Users/johnadmin/.bash_profile file was backed up as /Users/johnadmin/.bash_$
##
# MacPorts Installer addition on 2012-12-06_at_13:40:25: adding an appropriate PATH variable$
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
在我的智慧结束时,因为我不知道还有什么可以坦率地检查,任何帮助都将是一个很大的帮助。钽 约翰
答案 0 :(得分:0)
在尝试各种解决方案几个小时之后,我发现创建一个PHPUnit文件夹的符号链接工作没事。
我使用的命令是
sudo ln -s /Users/johnadmin/pear/share/pear/PHPUnit /usr/lib/php/PHPUnit
答案 1 :(得分:0)
说真的,这给了我很多帮助:
composer require phpunit/phpunit 3.7.*
composer update
将PHPUnit源和二进制拉入项目的三个简单步骤。