【问题标题】:PHP - Is there a portable version of PHPUnit?PHP - 是否有 PHPUnit 的可移植版本?
【发布时间】:2011-06-15 15:07:21
【问题描述】:

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

【问题讨论】:

标签: php phpunit


【解决方案1】:

便携式phpunit(取自https://github.com/sebastianbergmann/phpunit“Using PHPUnit From a Git Checkout”)

对于 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 ..

然后将这些文件夹中的每一个放入您的包含路径中。

如果您遗漏其中任何一个包,它将无法正常工作。

如果您不想总是将它们放在包含路径中,这里是一个 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 $*

【讨论】:

    【解决方案2】:

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

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

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

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

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

    【讨论】:

      【解决方案3】:

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

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

      这是我为 https://github.com/kblomqvist/gitinstall-phpunit 制作的 PHPUnit Git checkout 的安装程序。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-09-22
        • 1970-01-01
        • 2022-07-07
        • 2013-12-14
        • 1970-01-01
        • 2017-03-11
        • 1970-01-01
        相关资源
        最近更新 更多