Cannot get PHPunit working(无法让 PHPunit 工作)
问题描述
我一直在努力让 PHPunit 为我的 zend 框架项目工作,但遇到了各种问题.我已经重新安装了 PEAR 并卸载了 PHPunit,并重新安装了它们.
I have been tring to get PHPunit working for my zend framework project and have been encountering various problems. I have reinstalled PEAR and uninstalled PHPunit, and reinstalled them both.
我目前的错误是
demian@dimbo-TP:~$ phpunitPHP警告:require_once(PHPUnit/Framework/MockObject/Autoload.php):无法打开流:第48行的/usr/share/php/PHPUnit/Autoload.php中没有这样的文件或目录PHP 致命错误:require_once():在/usr/share/php/PHPUnit/Autoload.php 在第 48 行
demian@dimbo-TP:~$ phpunit PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48 PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/usr/share/php/:/usr/local/share/php/library') in /usr/share/php/PHPUnit/Autoload.php on line 48
我使用的是 ubuntu 11.10,PHP 5.3.6-13ubuntu3.2
I am using ubuntu 11.10, PHP 5.3.6-13ubuntu3.2
如果有人能给我一些指示,我将不胜感激.我在谷歌上看了很多,但似乎没有解决我的问题.
I would be very grateful if someone could give me some pointers. I have looked plenty on google, but nothing seems to solve my problem.
谢谢,
德米安.
这是我的 shell 转储,它显示了我最近所做的事情:
Here is my shell dump which shows what I have done recently:
demian@dimbo-TP:~$ phpunit
The program 'phpunit' is currently not installed. You can install it by typing:
sudo apt-get install phpunit
demian@dimbo-TP:~$ sudo pear channel-discover pear.phpunit.de
[sudo] password for demian:
Channel "pear.phpunit.de" is already initialized
demian@dimbo-TP:~$ sudo pear channel-discover pear.symfony-project.com
Channel "pear.symfony-project.com" is already initialized
demian@dimbo-TP:~$ sudo pear channel-discover components.ez.no
Channel "components.ez.no" is already initialized
demian@dimbo-TP:~$ sudo pear update-channels
Updating channel "components.ez.no"
Channel "components.ez.no" is up to date
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pear.phpunit.de"
Channel "pear.phpunit.de" is up to date
Updating channel "pear.symfony-project.com"
Channel "pear.symfony-project.com" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
demian@dimbo-TP:~$ sudo pear upgrade-all
Will upgrade channel://pear.php.net/benchmark
downloading Benchmark-1.2.8.tgz ...
Starting to download Benchmark-1.2.8.tgz (8,352 bytes)
.....done: 8,352 bytes
upgrade-all ok: channel://pear.php.net/Benchmark-1.2.8
demian@dimbo-TP:~$ sudo pear install --force --alldeps phpunit/PHPUnit
downloading PHPUnit-3.6.3.tgz ...
Starting to download PHPUnit-3.6.3.tgz (116,362 bytes)
.........................done: 116,362 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.6.3
demian@dimbo-TP:~$ pear install phpunit/PHP_CodeCoverage
phpunit/PHP_CodeCoverage is already installed and is the same as the released version 1.1.1
install failed
demian@dimbo-TP:~$ phpunit
PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open
stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48
PHP Fatal error: require_once(): Failed opening required
'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/usr/share/php/:/usr/local/share/php/library') in /usr/share/php/PHPUnit/Autoload.php on line 48
demian@dimbo-TP:~$ pear install phpunit
Warning: lstat(): Lstat failed for /tmp/pear/cache/312d32445ed39d8611ead5ee1d8cd72frest.cacheid in PEAR/REST.php on line 276
PHP Warning: lstat(): Lstat failed for /tmp/pear/cache/312d32445ed39d8611ead5ee1d8cd72frest.cacheid in /usr/share/php/PEAR/REST.php on line 276
No releases available for package "pear.php.net/phpunit"
install failed
demian@dimbo-TP:~$ sudo pear install phpunit
WARNING: "pear/PHPUnit" is deprecated in favor of "phpunit/PHPUnit"
Did not download dependencies: pear/PHP_Compat, use --alldeps or --onlyreqdeps to download automatically
pear/PHPUnit can optionally use package "pear/PHP_Compat"
downloading PHPUnit-1.3.2.tgz ...
Starting to download PHPUnit-1.3.2.tgz (20,913 bytes)
........done: 20,913 bytes
install ok: channel://pear.php.net/PHPUnit-1.3.2
demian@dimbo-TP:~$ phpunit
PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/usr/share/php/:/usr/local/share/php/library') in /usr/share/php/PHPUnit/Autoload.php on line 48
demian@dimbo-TP:~$ sudo pear uninstall phpunit
uninstall ok: channel://pear.php.net/PHPUnit-1.3.2
demian@dimbo-TP:~$ ^C
demian@dimbo-TP:~$ pear install phpunit/PHPUnit
phpunit/PHPUnit is already installed and is the same as the released version 3.6.3
install failed
demian@dimbo-TP:~$ phpunit
PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/usr/share/php/:/usr/local/share/php/library') in /usr/share/php/PHPUnit/Autoload.php on line 48
demian@dimbo-TP:~$ pear install --force phpunit/PHPUnit
WARNING: configuration download directory "/tmp/pear/download" is not writeable. Change download_dir config variable to a writeable dir to avoid this warning
Cannot install, php_dir for channel "pear.phpunit.de" is not writeable by the current user
demian@dimbo-TP:~$ sudo pear install phpunit/PHPUnit
phpunit/PHPUnit is already installed and is the same as the released version 3.6.3
install failed
demian@dimbo-TP:~$ pear install --force phpunit/PHPUnit
WARNING: configuration download directory "/tmp/pear/download" is not writeable. Change download_dir config variable to a writeable dir to avoid this warning
Cannot install, php_dir for channel "pear.phpunit.de" is not writeable by the current user
demian@dimbo-TP:~$ sudo pear install --force phpunit/PHPUnit
Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
downloading PHPUnit-3.6.3.tgz ...
Starting to download PHPUnit-3.6.3.tgz (116,362 bytes)
.........................done: 116,362 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.6.3
demian@dimbo-TP:~$ phpunit
PHP Warning: require_once(PHPUnit/Framework/MockObject/Autoload.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 48
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/MockObject/Autoload.php' (include_path='.:/usr/share/php/:/usr/local/share/php/library') in /usr/share/php/PHPUnit/Autoload.php on line 48
推荐答案
它选择了正确的 phpunit,但其他包丢失.您应该可以使用
It picks up the right phpunit but the other packages are missing. You should be able to fix this using
sudo pear install --alldeps --force phpunit/phpunit
或者如果您只想更新似乎是问题的库:
or if you want to only update the lib that seems to be the issue:
sudo pear install --force phpunit/PHPUnit_MockObject
Windows 用户:如果您使用的是 Windows 平台,请省略sudo"
Windows Users: Omit "sudo"if you are on windows platform
这篇关于无法让 PHPunit 工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法让 PHPunit 工作
基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01