Phing can't see PHPUnit

别说谁变了你拦得住时间么 提交于 2019-12-20 03:28:08

问题


I'm trying to setup a new Continuous Integration server that utilizes Phing and PHPUnit for automatically running test cases.

I've installed Phing with Pear:

pear channel-discover pear.phing.info
pear install phing/phing

I've installed PHPUnit using the new PHAR method:

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

Then I go to the directory where my build.xml file is located, rung phing and it looks like Phing has no idea where PHPUnit is.

[jenkins@leroy workspace]$ phing
Buildfile: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml

Framework > test:

 [echo] Running Tests
Execution of target "test" failed for the following reason: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: PHPUnitTask requires PHPUnit to be installed

BUILD FAILED
/home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37:
/home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: PHPUnitTask requires PHPUnit to be installed
Total time: 0.0764 seconds

[jenkins@leroy workspace]$

Checked the location of Phing and PHPUnit:

[jenkins@leroy workspace]$ which phing
/usr/bin/phing
[jenkins@leroy workspace]$ which phpunit
/usr/local/bin/phpunit

And, making sure PHP is new enough:

[jenkins@leroy workspace]$ php -v
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 

I'm doing all of this because we're replacing an older Jenkins server with this new one. Trying to use the newest software, but I can't figure out how to tell Phing where to find PHPUnit.

Thanks in advance for any help!

David


回答1:


Seems like adding the pharlocation attribute to the phpunit task element, pointing to your local phpunit executable, does the job:

<phpunit haltonfailure="true" haltonerror="true" 
    bootstrap="./fw_init.php" 
    pharlocation="/usr/local/bin/phpunit">
        <formatter type="plain" usefile="false" />
        ...
</phpunit>



回答2:


It looks like there are some actual issues with phing and the latest 4.x versions of PHPUnit: http://www.phing.info/trac/ticket/1091.

So to fix the issue, I removed PHPUnit 4 and specified an older version:

pear install phpunit/PHPUnit-3.7.35

Phing and PHPUnit worked immediately at this point.




回答3:


Here is a guy with exactly the same problem: How do I tell Phing where PHPUnit is installed?

His theory is that:

PHP version on this machine could be too old and not be able to handle PHAR archives

I can't comment if he is right or not, but that question received no replies from anyone other than the author




回答4:


Maybe a silly remark, but do you have /usr/local/bin/phpunit in your PHP include path?

I get the same error when I remove the location of phpunit.phar from my include path.



来源:https://stackoverflow.com/questions/23377750/phing-cant-see-phpunit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!