简体   繁体   English

使用@runInSeparateProcess的PHPStorm 8和PHPUnit问题

[英]PHPStorm 8 and PHPUnit problems with @runInSeparateProcess

I am running phpunit (composer provisioned and version 4.8) from PHPStorm 8. Usually it works fine but whenever I need to use the @runInSeparateProcess annotation it starts screaming this error: 我正在从PHPStorm 8运行phpunit(配置了复合程序且版本为4.8)。通常它可以正常工作,但是每当我需要使用@runInSeparateProcess批注时,它就会开始发出此错误消息:

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

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

The PHPUnit configuration on the IDE is the following: IDE上的PHPUnit配置如下:

  • Language & Frameworks > PHP > PHPunit: custom autoloader pointing to codebase /vendor/autoload.php 语言与框架> PHP> PHPunit:指向代码库 /vendor/autoload.php的自定义自动加载器
  • Run/Debug Configuration: alternative configuration file which point to my local phpunit.xml 运行/调试配置:指向我的本地phpunit.xml的备用配置文件

This is the content of the configuration: 这是配置的内容:

<?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>

The tests run as expected from the command line with the same phpunit executable and the same configuration file. 这些测试将使用相同的phpunit可执行文件和相同的配置文件从命令行按预期运行。

Any suggestion? 有什么建议吗?

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

A modification of the fix the folks over at Drupal are using ( https://www.drupal.org/node/2597814 ) 在Drupal上使用的修复程序的修改( https://www.drupal.org/node/2597814

Add to the top of your boostrap file: 添加到您的boostrap文件的顶部:

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

I tried many other methods, including upgrading PHPStorm and up/down-grading PHPUnit. 我尝试了许多其他方法,包括升级PHPStorm和升级/降级PHPUnit。 This works. 这可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM