^如何配置phing build.xml以使用Drupal Aotoloader

时间:2019-07-04 10:27:50

标签: phpunit drupal-8 phing phpunit-testing

我已经完成了一个drupal 8路径的根目录下的build.xml,并且当我在phpunit测试中运行./vendor/bin/phing或其他将xml日志转换为html时,我没有预期结果。那么我该如何修改build.xml

这里提供给我灵感的链接https://cweiske.de/tagebuch/visualizing-phpunit-runs.htm

我的build.xml

<project name="svie_tarificateur_report" default="spheria-report" basedir=".">
    <!--<taskdef name="myecho" classname="MyEchoTask" />-->
 <target name="spheria-report">
     <echo msg="Hello, Doric!" />
     <autoloader autoloaderpath="./autoload.php"/>
  <phpunitreport infile="log.junit.xml"
                 format="frames"
                 todir="html"
                 styledir="/usr/share/php/data/phing/etc/"
                 />
 </target>
</project>

我的phpunit日志

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="modules/custom" tests="2" assertions="2" errors="0" failures="0" skipped="0" time="0.008327">
    <testsuite name="Drupal\Tests\svie_tarificateur\Unit\CalculateurTest" file="/var/www/html/modules/custom/svie_tarificateur/tests/src/Unit/CalculateurTest.php" tests="2" assertions="2" errors="0" failures="0" skipped="0" time="0.008327">
      <testcase name="testAgeSouscription" class="Drupal\Tests\svie_tarificateur\Unit\CalculateurTest" classname="Drupal.Tests.svie_tarificateur.Unit.CalculateurTest" file="/var/www/html/modules/custom/svie_tarificateur/tests/src/Unit/CalculateurTest.php" line="43" assertions="1" time="0.008219"/>
      <testcase name="testAssureNo" class="Drupal\Tests\svie_tarificateur\Unit\CalculateurTest" classname="Drupal.Tests.svie_tarificateur.Unit.CalculateurTest" file="/var/www/html/modules/custom/svie_tarificateur/tests/src/Unit/CalculateurTest.php" line="50" assertions="1" time="0.000108"/>
    </testsuite>
  </testsuite>
</testsuites>

我希望A有一个生成的html,但我有此错误 [root @ d15936c9eaa8 html]#./vendor/bin/phing 构建文件:/var/www/html/build.xml

svie_tarificateur_report> spheria报告:

 [echo] Hello, Doric!

[autoloader]从./autoload.php加载自动加载器

建立失败 ReflectionException:在/var/www/html/vendor/phing/phing/classes/phing/tasks/ext/phpunit/PHPUnitReportTask.php:229中不存在类Drupal \ Tests \ svie_tarificateur \ Unit \ CalculateurTest 堆栈跟踪:

0 /var/www/html/vendor/phing/phing/classes/phing/tasks/ext/phpunit/PHPUnitReportTask.php(229):ReflectionClass-> __ construct('Drupal \ Tests \ sv ...')

1 /var/www/html/vendor/phing/phing/classes/phing/tasks/ext/phpunit/PHPUnitReportTask.php(269):PHPUnitReportTask-> fixDocument(Object(DOMDocument))

2 /var/www/html/vendor/phing/phing/classes/phing/UnknownElement.php(100):PHPUnitReportTask-> main()

3 /var/www/html/vendor/phing/phing/classes/phing/Task.php(283):UnknownElement-> main()

4 /var/www/html/vendor/phing/phing/classes/phing/Target.php(336):Task-> perform()

5 /var/www/html/vendor/phing/phing/classes/phing/Target.php(366):Target-> main()

6 /var/www/html/vendor/phing/phing/classes/phing/Project.php(898):Target-> performTasks()

7 /var/www/html/vendor/phing/phing/classes/phing/Project.php(868):Project-> executeTarget('spheria-report')

8 /var/www/html/vendor/phing/phing/classes/phing/Phing.php(723):Project-> executeTargets(Array)

9 /var/www/html/vendor/phing/phing/classes/phing/Phing.php(200):Phing-> runBuild()

10 /var/www/html/vendor/phing/phing/classes/phing/Phing.php(347):Phing :: start(Array,NULL)

11 /var/www/html/vendor/phing/phing/bin/phing.php(58):Phing :: fire(Array)

12 / var / www / html / vendor / phing / phing / bin / phing(14):require_once('/ var / www / html / v ...')

13 {main}

总时间:0.1182秒

因为找不到我的drupal课程

1 个答案:

答案 0 :(得分:0)

如果您使用的是Composer,则autoload.php文件位于供应商目录中,请尝试如下操作:

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