【问题标题】:phpunit installed via composer, tell phing to use that通过composer安装的phpunit,告诉phing使用它
【发布时间】:2016-03-29 23:46:03
【问题描述】:

我似乎无法让 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-target。此外,全局安装的 phpunit 也不是我想要的,因为我不希望开发人员之间存在版本差异。

【问题讨论】:

    标签: php phpunit composer-php phing


    【解决方案1】:

    您是否已经尝试过 Phing 自动加载任务?

    https://www.phing.info/docs/guide/trunk/AutoloaderTask.html

    我是这样使用它的:

    【讨论】:

    • 很遗憾你没有用你自己的例子来完成你的答案。就我而言,添加一个简单的<autoloader /> 就足够了。在本地安装 phing 的情况下,这比我的回答要好。如果 phing 本身作为 Composer 依赖项安装,则不需要此步骤。
    【解决方案2】:

    将您的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

    【讨论】:

      【解决方案3】:

      Phing 使用您的项目本地库,包括 PHPUnit 库,您不必明确提及 bin/phpunit 可执行文件。

      我不知道 phing 如何知道查看项目本地依赖项。

      【讨论】:

        【解决方案4】:

        我设法修复它自动加载 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>
        

        【讨论】:

        • 对我不起作用,仍然得到PHPUnitTask requires PHPUnit to be installed
        猜你喜欢
        • 1970-01-01
        • 2014-12-25
        • 2023-04-04
        • 2013-09-12
        • 2015-01-21
        • 2011-08-01
        • 2014-07-26
        • 1970-01-01
        • 2017-11-10
        相关资源
        最近更新 更多