首页 > 解决方案 > PhpStorm 2018.2,PHPUnit 5.7.27。进程以退出代码 255 结束

问题描述

使用 Laravel 5.3、PHP 5.6 并尝试测试包的类。

这是我的测试课

class OrderQuoteStrategyTest extends TestCase {

    public function testCanSendQuote() {
        $order=$this->createOrder();
        $orderSpec=new Orderspec();

        $this->expectException( \Exception::class);
        $this->expectExceptionMessage( 'Order must be waiting for Quote');

        $orderQuoteStrategy= new OrderQuoteStrategy();
        $orderQuoteStrategy->canSendQuote( $order, $orderSpec );
    }
}

右键单击并“运行 OrderQuoteStrategyTest (PHPUnit)”,出现以下错误。

Process finished with exit code 255

标签: phplaravelphpstorm

解决方案


我不得不发布这种问答风格来帮助遇到我的情况的其他人。

在检查 php_error_log 时:

 PHP Parse error:  syntax error, unexpected ':', expecting ';' or '{' in \vendor\doctrine\instantiator\src\Doctrine\Instantiator\Instantiator.php on line 95

似乎作曲家已将 'doctrine/instantiator' 更新为仅与 PHP 7 兼容的最新版本。

对于解决方案,将此添加到 require-dev :

  "doctrine/instantiator": "1.0.5"

并运行作曲家更新。

再次运行上述测试没有错误。


推荐阅读