共享服务器上的PHPUnit和Yii [英] PHPUnit and Yii on a shared server

查看:74
本文介绍了共享服务器上的PHPUnit和Yii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了PHPUnit并检查了PEAR设置,然后一切正常.我正在使用Yii作为框架,并且我在linux共享服务器上.当我运行测试(任何测试)时,出现以下错误.据我所知,我需要在路径设置中添加以下内容:

I have installed PHPUnit and checked my PEAR settings and everything went fine. I'm using Yii as my framework and I am on a linux shared server. When I run a test (any test) I get the errors below. From what I can tell I think I need to add the following to my path settings:

/home/myname/php/  

,因为这是PHP和PHPUnit文件夹所在的位置.由于我位于共享服务器上,因此无法修改php.ini文件.我想知道这是否真的是问题,是否有人在共享环境中找到并解决了此问题?

since that is where both the PHP and PHPUnit folders are located. I am unable to modify the php.ini file since I am on a shared server. I am wondering if this is really the problem and if anyone else has found and fixed this issue in a shared environment?

/protected/tests/unit]# phpunit dbTest.php
X-Powered-By: PHP/5.2.9
Content-type: text/html

<br />
<b>Warning</b>:  require_once(PHPUnit/Util/Filter.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /home/myname/bin/phpunit on line 40<br />
<br />
<b>Fatal error</b>:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myname/bin/phpunit on line 40

推荐答案

经过反复的试验和磨难,我弄清楚了.希望这对其他人有帮助.

After much trial and tribulation I figured it out. Hope this helps someone else.

由于我位于共享服务器上,因此无法调整include_path.使用.htaccess文件也不起作用,因为phpunit是从命令行运行的,并且不会调用.htaccess文件.因此,如果您遇到与phpunit相同的问题,则在.htaccess中设置一个include路径是徒劳的.

Since I am on a shared server I cannot adjust the include_path. It won't work using a .htaccess file either because phpunit is run from the command line and doesn't invoke the .htaccess file. Therefore, setting an include path in a .htaccess is fruitless if you're having the same problems as I was with phpunit.

我现在能够从中运行phpunit测试的唯一路径是/home/myname/php.那是因为我的PHPUnit文件自动安装在/home/myname/php/PHPUnit中.

The only path that I am now able to get phpunit tests to run from is /home/myname/php. That is because my PHPUnit files automatically install in /home/myname/php/PHPUnit.

从/home/myname/php运行phpunit测试时,我会得到一个错误提示

When running a phpunit test from /home/myname/php I would get an error stating

File &quot;/home/... &quot; could not be found

这时我发现我需要升级PHPUnit,这又升级了它的一些依赖项(CodeCoverage,Selenium和其他).升级phpunit的命令是

At this point I found that I needed to upgrade PHPUnit, which in turn upgraded a number of its dependencies (CodeCoverage, Selenium and others). The command to upgrade phpunit was

pear upgrade phpunit/PHPUnit

现在,我可以从/home/myname/php文件夹成功运行测试,并且可以运行.如果我从任何其他文件夹运行测试,它将失败,因为它正在搜索include_path目录,并且/home/myname/php不是这些路径之一.

Now I can successfully run tests from the /home/myname/php folder and it works. If I run the tests from any other folder it fails because it is searching the include_path directories and /home/myname/php is not one of those paths.

这篇关于共享服务器上的PHPUnit和Yii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆