加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

麻烦包括PHPUnit

发布时间:2021-08-28 03:47:18 所属栏目:大数据 来源: https://www.jb51.cc
导读:我想开始为我的代码编写测试,所以我使用以下命令安装了最新的PHPUnit wget http://pear.PHPunit.de/get/PHPunit.pharchmod +x PHPunit.pharmv PHPunit.phar /usr/local/bin/PHPunit http://phpunit.de/manual/3.8/en/installation.html 然后我将/usr/local/b

我想开始为我的代码编写测试,所以我使用以下命令安装了最新的PHPUnit

wget http://pear.PHPunit.de/get/PHPunit.phar
chmod +x PHPunit.phar
mv PHPunit.phar /usr/local/bin/PHPunit

http://phpunit.de/manual/3.8/en/installation.html

然后我将/usr/local/bin添加到我的PHP.ini include路径,看起来像这样

include_path =“.:/ Applications / MAMP / bin / PHP / PHP5.4.10 / lib / PHP:/usr/local/bin”

但是当我访问/my-app/test.PHP时,我收到以下错误

Warning (2): include(PHPUnit/Autoload.PHP): Failed to open stream: No
such file or directory
[CORE/Cake/TestSuite/CakeTestSuiteDispatcher.PHP, line 150]

Warning (2): include() [function.include]: Failed opening
‘PHPUnit/Autoload.PHP’ for inclusion
(include_path=’/Users/DevinCrossman/Sites/studio-bliss/lib:.:/Applications/MAMP/bin/PHP/PHP5.4.10/lib/PHP:/usr/local/bin’)
[CORE/Cake/TestSuite/CakeTestSuiteDispatcher.PHP, line 150]

我尝试将/usr/local/bin / PHPunit更改为/usr/local/bin / PHPUnit,但这不起作用.我也尝试将include路径从/usr/local/bin更改为/usr/local/bin / PHPunit并重新启动apache(我在这台机器上使用MAMP PRO,但它也无法在我的ubuntu服务器上运行)

PHPinfo()显示正确设置了包含路径.

我错过了很明显的事情.谁能告诉我为什么这不起作用?

解决方法:

CakePHP recommends using PEAR to install PHPUnit.在你的情况下它应该更好.

将phar放在带有文件名’PHPunit’的/usr/local/bin中意味着运行PHPUnit’s testrunner via the command line,因为它将使PHPunit命令可用.例如运行命令:

PHPunit MyTest test.PHP

在浏览器中运行时,您需要加载可用的PHPUnit类,只需在include路径中包含指向phar的路径即可.
我不确定但是如果你将phar包含在你的测试文件中它可能会有效:

require_once '/path/to/PHPunit.phar'

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读