簡體   English   中英

無法全局安裝舊版本的 phpunit phar

[英]Unable to globally install older version of phpunit phar

https://phpunit.de/manual/current/en/installation.html#installation.phar.verification中所述,全局安裝 PHAR 的步驟是:

$ wget https://phar.phpunit.de/phpunit.phar
$ chmod +x phpunit.phar
$ sudo mv phpunit.phar /usr/local/bin/phpunit
$ phpunit --version
PHPUnit x.y.z by Sebastian Bergmann and contributors.

我按照上面的,但使用舊版本的 URL,即https://phar.phpunit.de/phpunit-old.phar (因為我們的 PHP 版本較舊)。 然后我運行了以下命令 -

$ chmod +x phpunit-old.phar
$ sudo mv phpunit-old.phar /usr/local/bin/phpunit

注意 - 我的 PHP 版本是 5.3.29。 phpunit.de 中的 Old Stable Release 部分說 PHPUnit 4.8 支持 PHP 5.3、PHP 5.4、PHP 5.5 和 PHP 5.6。

到這里看起來還不錯。 但是,運行phpunit --version給出 -

PHP Fatal error:  require(): Cannot redeclare class phpunit_extensions_database_constraint_tableisequal in /usr/local/bin/phpunit on line 109
zend_mm_heap corrupted

因此,我沒有將.phar移動到/usr/local/bin/ (在第 3 步中),而是通過運行它來管理到目前為止 -

$ php phpunit-old.phar –-version 

我還能夠以這種方式運行我的單元測試用例 -

php /home/sandeepan/phpunit-old.phar /var/cake_1.2.0.6311-beta/app/webroot/openx/lib/ad_agencies/unittests/Admarvel_generic_network_test.php

但是,現在我需要將 phpunit 與 phing 集成。 我想使用phing 的 PHPUnitTask提供的基本實用程序。 所以,我想它需要全局安裝 phpunit phar。

我通過編寫以下內容來嘗試運氣 -

<phpunit haltonfailure="true" haltonerror="true" 
                                            pharlocation="/home/sandeepan/phpunit-old">
    <formatter type="plain" usefile="false" />
    <batchtest>
        <fileset dir="${dir.scratchpad}/${dir.subdir}/unittests">
            <include name="**/*_test.php"/>
        </fileset>
    </batchtest>
</phpunit>

但我收到這個錯誤 -

BUILD FAILED
...
: PHPUnitTask requires PHPUnit to be installed

更新

參考stackoverflow.com/a/23410676/351903,我嘗試使用這個舊版本的Phpunit,即PHPUnit-3.7.35。 現在, phpunit --version命令起作用了。 但是我仍然沒有成功使用 Phing 的 PHPUnitTask。 仍然得到PHPUnitTask requires PHPUnit to be installed錯誤。

更新 2

對我有用的解決方案是使用 PHPUnit 3.7.35。 PHPUnit 4.8 的 phing 似乎存在一些兼容性問題。

我剛剛從 phpunit.de 網站下載了您提供的舊 PHPUnit 文件,並成功應用了您編寫的命令。 在我的情況下,運行 phpunit 就像一個魅力。

也許您的 PHP 版本與您下載的 PHPUnit 版本不兼容?

我無法重現您描述的問題:

$ wget https://phar.phpunit.de/phpunit-old.phar
--2016-04-07 09:47:35--  https://phar.phpunit.de/phpunit-old.phar
Resolving phar.phpunit.de (phar.phpunit.de)... 188.94.27.25
Connecting to phar.phpunit.de (phar.phpunit.de)|188.94.27.25|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://phar.phpunit.de/phpunit-4.8.24.phar [following]
--2016-04-07 09:47:35--  https://phar.phpunit.de/phpunit-4.8.24.phar
Reusing existing connection to phar.phpunit.de:443.
HTTP request sent, awaiting response... 200 OK
Length: 3086772 (2.9M) [application/octet-stream]
Saving to: ‘phpunit-old.phar’

phpunit-old.phar                                          100%[=====================================================================================================================================>]   2.94M  3.97MB/s    in 0.7s    

2016-04-07 09:47:36 (3.97 MB/s) - ‘phpunit-old.phar’ saved [3086772/3086772]


$ php phpunit-old.phar --version
PHPUnit 4.8.24 by Sebastian Bergmann and contributors.

對我有用的解決方案是使用 PHPUnit 3.7.35。 PHPUnit 4.8 的 phing 似乎存在一些兼容性問題。

源 - Phing 看不到 PHPUnit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM