我似乎无法让Phing使用通过composer安装的PHPUnit(在项目本地bin/
目录中)。最后,如果我告诉Phing使用我的phpunit可执行文件,就好像它是一个使用<phpunit pharlocation="${basedir}/bin/phpunit" />
的PHAR文件一样
但这也失败了:
Project > phpunit:
#!/usr/bin/env php
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
unrecognized option -- f
我宁愿不修改我的PATH,因为其他开发人员应该能够运行phing phpunit目标,而不会有任何大麻烦。此外,全局安装的phpunit不是我想要的,因为我不希望开发人员之间存在版本差异。
您是否已经尝试过Phing自动加载任务?
https://www.phing.info/docs/guide/trunk/AutoloaderTask.html
我是这样使用它的:
将PhpunitTask
转换为ExecTask
应该会有所帮助:
<target name="phpunit">
<exec logoutput="true" checkreturn="true" dir="${basedir}" command="bin/phpunit" />
</target>
有关参考,请参见https://www.phing.info/docs/guide/trunk/ExecTask.html.
Phing使用您的项目本地库,包括PHPUnit库,您不应该明确提及bin/phpunit
可执行文件。
我不知道phing是如何看待项目的本地依赖关系的。
我通过自动加载composer/autoload.php文件修复了它
<project name="name" default="build">
<autoloader autoloaderpath="${baseDir}/vendor/autoload.php"/>
<target name="tests">
<phpunit bootstrap="${testsDir}/bootstrap.php" >
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="${testsDir}">
<include name="**/*Test*.php"/>
</fileset>
</batchtest>
</phpunit>
</target>
</project>