Phing和PHPUnit,甚至无法运行最基本的东西 [英] Phing and PHPUnit, just cant get even the most basic thing running

查看:123
本文介绍了Phing和PHPUnit,甚至无法运行最基本的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行以下最基本的任务:

I'm running a most basic task as follows:

<autoloader autoloaderpath="vendor/autoload.php">

<target name="asdf">
        <echo msg="test"/>
        <phpunit configuration="app/phpunit.xml"
                 haltonerror="true"
                 haltonfailure="true"
                 pharlocation="bin/phpunit"
        />
</target>

现在只需运行此任务即可:

Now simply running this task:

phing -debug asdf

将导致:

  +Task: echo
    -calling setter EchoTask::setMsg()
     [echo] qwerqwer
  +Task: phpunit
    -calling setter PHPUnitTask::setConfiguration()
    -calling setter PHPUnitTask::setHaltonerror()
    -calling setter PHPUnitTask::setHaltonfailure()
    -calling setter PHPUnitTask::setPharLocation()
#!/usr/bin/env php
Cannot open file "asdf.php".

使用.phar

使用与重新分配相同的配置:

Using a .phar

Using the same configuration except pharlocation:

  +Task: echo
    -calling setter EchoTask::setMsg()
     [echo] test
  +Task: phpunit
    -calling setter PHPUnitTask::setConfiguration()
    -calling setter PHPUnitTask::setHaltonerror()
    -calling setter PHPUnitTask::setHaltonfailure()

BUILD FINISHED

没有错误,但是phpunit任务类型没有启动.

No errors, but the phpunit tasktype doesnt start.

有第三个看起来很不错的简单变体,导致产生了"phpunit:无法识别的选项-p",可悲的是我无法复制..

Had a third simple variant that seemed fine, which resulted in 'phpunit: unrecognized option -- p' that i sadly cant reproduce..

  • PU 5.7
  • Phing 2.16
  • PHP 7.1

推荐答案

我看到您使用了PHPUnit 5.7.您在测试中使用名称空间了吗?

I see you used PHPUnit 5.7. Did you use namespaces in your tests?

当前版本的Phing与PHPUnit\Framework\TestCase之类的命名空间不兼容,您必须使用旧的类\PHPUnit_Framework_TestCase.

The current version of Phing is not compatible with namespaces like PHPUnit\Framework\TestCase, you have to use the old class \PHPUnit_Framework_TestCase instead.

下一个Phing的发行版将与PHPUnit的命名空间兼容( https://github. com/phingofficial/phing/issues/659 ).同时,您可以创建phpunit.xml并将其添加到build.xml来运行测试:

The next Phing's release is going to be compatible with PHPUnit's namespaces (https://github.com/phingofficial/phing/issues/659). Meanwhile you can create phpunit.xml and add this to build.xml to run your tests:

<target name="phpunit" description="Run tests">
    <exec executable="bin/phpunit" passthru="true">
        <arg value="--configuration"/>
        <arg value="app/phpunit.xml"/>
    </exec>
</target>

这篇关于Phing和PHPUnit,甚至无法运行最基本的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆