PHP - 是否有PHPUnit的可移植版本?

时间:2011-01-26 03:27:29

标签: php phpunit

我是否可以通过我的网络应用程序捆绑可移植版本的PHPUnit?我希望能够在任何服务器上使用phpunit,同时避免使用PEAR(版本冲突,破坏其他托管应用程序等)的问题。

3 个答案:

答案 0 :(得分:8)

便携式phpunit(取自https://github.com/sebastianbergmann/phpunit“使用来自Git Checkout的PHPUnit”)

对于phpunit 3.5:

git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git

cd phpunit && git checkout 3.5 && cd ..
cd dbunit && git checkout 1.0 && cd ..
cd php-file-iterator && git checkout 1.2 && cd ..
cd php-code-coverage && git checkout 1.0 && cd ..
cd php-token-stream && git checkout 1.0 && cd ..
cd phpunit-mock-objects && git checkout 1.0 && cd ..
cd phpunit-selenium && git checkout 1.0 && cd ..

然后将每个文件夹放入包含路径。

如果您遗漏任何一个包,它将无效。

如果您不想在include路径中始终使用它们,那么这是一个phpunit.sh可执行文件

phpunit.sh

x='./checkoutDir/';

php -d include_path=".:$x/phpunit/:$x/dbunit/:$x/php-code-coverage/:$x/php-file-iterator/:$x/php-text-template/:$x/php-timer/:$x/php-token-stream/:$x/phpunit-mock-objects/:$x/phpunit-selenium/:$x/phpunit-story/:/usr/share/php/"  $x/phpunit/phpunit.php $*

答案 1 :(得分:3)

编写时answer by edorian was spot on(今天可能仍然有用)。但是,现在有一些更方便的选择供您使用。

除了fixing to a specific PhpUnit via Composer之外,您还可以将PHPUnit作为Phar下载并使用它。

引用https://github.com/sebastianbergmann/phpunit

  

我们分发一个PHP Archive(PHAR),它包含捆绑在一个文件中的PHPUnit的所有必需(以及一些可选)依赖项:

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

答案 2 :(得分:2)

edorian的回答错过了Symfony / Yaml包。此外,似乎需要Symfony / Finder,尽管在PHPUnit的自述文件中没有提到。

关于PEAR依赖,它只是PHPUnit的selftest,它往往需要它。至少我已经成功运行了Zend Framework 2的整个测试套件而没有任何问题。我没有安装PEAR。

这是PHPUnit Git checkout的安装程序,我已经https://github.com/kblomqvist/gitinstall-phpunit

相关问题