【问题标题】:PHPStorm 8 and PHPUnit problems with @runInSeparateProcess@runInSeparateProcess 的 PHPStorm 8 和 PHPUnit 问题
【发布时间】:2016-01-22 19:14:28
【问题描述】:

我正在从 PHPStorm 8 运行 phpunit(composer 配置和版本 4.8)。通常它工作正常,但每当我需要使用 @runInSeparateProcess 注释时,它就会开始尖叫这个错误:

Fatal error: Class 'PHPUnit_Util_Configuration' not found in - on line 334

Call Stack:
0.0013     395808   1. {main}() -:0

IDE 上的 PHPUnit 配置如下:

  • 语言和框架 > PHP > PHPunit:自定义自动加载器指向 codebase/vendor/autoload.php
  • 运行/调试配置:指向我本地 phpunit.xml 的替代配置文件

这是配置的内容:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
         colors="true"
         bootstrap="./vendor/autoload.php"
         backupGlobals="false"
         backupStaticAttributes="false"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false">

    <testsuites>
        <testsuite name="My Project">
            <directory>./tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">./src</directory>
        </whitelist>
    </filter>
</phpunit>

测试从命令行按预期运行,具有相同的 phpunit 可执行文件和相同的配置文件。

有什么建议吗?

【问题讨论】:

    标签: phpunit phpstorm


    【解决方案1】:

    显然删除所有依赖项并从 composer (phpunit 4.8.6) 重新安装 phpunit 解决了这个问题。

    【讨论】:

      【解决方案2】:

      Drupal 的人们正在使用的修复程序的修改 (https://www.drupal.org/node/2597814)

      添加到您的 boostrap 文件的顶部:

      if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
          define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/path/to/composer/vendors/dir/autoload.php');
      }
      

      我尝试了许多其他方法,包括升级 PHPStorm 和升级/降级 PHPUnit。这行得通。

      【讨论】:

        猜你喜欢
        • 2013-07-11
        • 2017-03-15
        • 2014-11-12
        • 2012-08-01
        • 2011-07-25
        • 2012-09-30
        • 2014-12-28
        • 2018-03-24
        • 1970-01-01
        相关资源
        最近更新 更多