Phing and PHPUnit, just cant get even the most basic thing running

天大地大妈咪最大 提交于 2019-12-11 05:16:07

问题


Using a composer-installed bin

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

Will result in:

  +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".

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

No errors, but the phpunit tasktype doesnt start.

Unrecognized option

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

Versions

  • PU 5.7
  • Phing 2.16
  • PHP 7.1

回答1:


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

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.

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>


来源:https://stackoverflow.com/questions/42907053/phing-and-phpunit-just-cant-get-even-the-most-basic-thing-running

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