phpunit和yii - (PHPUnit / Autoload.php):无法打开流:

时间:2012-04-06 20:25:22

标签: php yii phpunit

在使用Yii安装phpunit时遇到很多问题。我跑:

$ phpunit unit/dbTest.php

但事实证明这个错误:

  

PHP警告:require_once(PHPUnit / Autoload.php):无法打开流:第12行/opt/yii-1.1.10.r3566/framework/test/CTestCase.php中没有此类文件或目录

     

(include_path中=”:在/ usr / bin中:在/ usr /共享/ PHP:在/ usr / bin中/梨:在/ usr /共享/ PHP / Zend的/中:/ opt / php5.3.10 / LIB / PHP / PHPUnit的“

我的安装的一些细节:

$ phpunit --version
PHPUnit 3.4.5 by Sebastian Bergmann.

php --version
PHP 5.3.10 (cli) (built: Apr  6 2012 20:06:37) ( rebuilt didn't help :( )

pear list phpunit/phpunit
....
php    /opt/php5.3.10/lib/php/PHPUnit/Autoload.php

根据该信息,自动加载已安装,并且位于包含路径上。

我不确定我还需要做什么 - 有人可以点灯吗?

2 个答案:

答案 0 :(得分:3)

我希望这对某人有用:

似乎ubuntu PEAR已经完成此任务,apt-get也无济于事。

这就是我解决它的方式

http://pear.phpunit.de/

手动下载
phpunit/PHPUnit

phpunit/File_Iterator
PHPUnit_MockObject
phpunit/PHPUnit_Selenium
PHP_CodeCoverage

手动解压缩并正确放入php lib或任何你想要的地方。把这个库的头放在你的包含路径上(PHP,PHPlib,PEAR都在我的设置的这个根级别。)

Goddam,希望帮助我花了大约6个小时才能让这个人在最后一刻工作......

答案 1 :(得分:2)

正如rix在他的回答中所示,你必须手动下载一些文件。

我按照以下命令在Ubuntu 10.04上工作:

wget http://pear.phpunit.de/get/PHPUnit-3.6.10.tgz
wget http://pear.phpunit.de/get/File_Iterator-1.3.1.tgz
wget http://pear.phpunit.de/get/PHPUnit_MockObject-1.1.1.tgz
wget http://pear.phpunit.de/get/PHPUnit_Selenium-1.2.6.tgz
wget http://pear.phpunit.de/get/PHP_CodeCoverage-1.1.2.tgz
wget http://pear.phpunit.de/get/PHP_TokenStream-1.1.3.tgz
wget http://pear.phpunit.de/get/Text_Template-1.1.1.tgz
wget http://pear.phpunit.de/get/PHP_Timer-1.0.2.tgz

sudo vi /etc/php5/cli/php.ini

=>将/ usr / share / php / PHPUnit /添加到include_path指令

tar xzf PHPUnit-3.6.10.tgz 
cd PHPUnit-3.6.10/
sudo cp -r PHPUnit/ /usr/share/php/
sudo ln -s /usr/share/php/PHPUnit /usr/bin/PHPUnit

tar xzf File_Iterator-1.3.1.tgz
sudo cp -r File/ /usr/share/php/PHPUnit/

tar xzf PHP_CodeCoverage-1.1.2.tgz
cd PHP_CodeCoverage-1.1.2/
sudo cp -R PHP/ /usr/share/php/PHPUnit/

tar xzf PHP_TokenStream-1.1.3.tgz
cd PHP_TokenStream-1.1.3/PHP/
sudo cp -r Token* /usr/share/php/PHPUnit/PHP/

tar xzf Text_Template-1.1.1.tgz
cd Text_Template-1.1.1/
sudo cp -r Text/ /usr/share/php/PHPUnit/

tar xzf PHP_Timer-1.0.2.tgz 
cd PHP_Timer-1.0.2/
sudo cp -r PHP/Timer* /usr/share/php/PHPUnit/PHP/

tar xzf PHPUnit_MockObject-1.1.1.tgz
cd PHPUnit_MockObject-1.1.1/
sudo cp -r PHPUnit/Framework/MockObject/ /usr/share/php/PHPUnit/Framework/

tar xzf PHPUnit_Selenium-1.2.6.tgz
cd PHPUnit_Selenium-1.2.6/
sudo cp -r PHPUnit/Extensions/* /usr/share/php/PHPUnit/Extensions/