在共享服务器上安装PHPUnit

时间:2015-04-06 07:22:03

标签: php unit-testing phpunit

我正在尝试在共享托管服务器(即GoDaddy)上安装PHPUnit。在GoDaddy提供的cpanel中,我可以看到PHP Pear扩展,在搜索上只给了我phpunit1,phpunit2,它们是非常旧的版本,因为我们现在有phpunit 4.6。

此处的文档https://phpunit.de/manual/3.7/en/installation.html#installation.phar表示要使用

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit

当我进入我的共享主机,并做了一个wget它给了我许可否认。

我想知道是否有一种方法可以让godaddy共享主机使用cpanel来运行phpunit4.6。如果没有,我可以简单地在现有框架内下载phpunit并开始参考phpunit框架来编写我的测试用例吗?

2 个答案:

答案 0 :(得分:1)

您要做的是全局安装PHPUnit。我从来没有使用过GoDaddy,但我可以假设,因为它是一个共享主机,你将不会被允许将phpunit.phar移动到bin文件夹。

尝试将其保留在本地文件夹中。这应该没有任何问题。

您也可以使用composer来安装它。看看这里的官方文档: https://phpunit.de/manual/current/en/installation.html

答案 1 :(得分:0)

在搜索如何在GoDaddy帐户上为CakePHP 2安装PHPUnit时找到这个。

CakePHP会自动将其添加到include_path并获取PHPUnit的Autoloader.php

现在,问题不在于具体的CakePHP。在这种情况下,只需确保PHPUnit在您的包含路径中(您可以通过从命令行运行php -i | grep include_path来阅读它,或者只是调用phpinfo()