php - 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
解决方案
我不得不发布这种问答风格来帮助遇到我的情况的其他人。
在检查 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"
并运行作曲家更新。
再次运行上述测试没有错误。
推荐阅读
- javascript - 链接不使用 React DOM 路由器重定向
- java - 从命令行检查字符数
- r - 使用 Powershell 的 Rscript.exe 表达式中的双引号
- spring-mvc - 在 jboss 7 上部署 spring mvc 时出现 404 错误
- java - 在控制台中显示来自文本文件的信息
- python - 将变量插入正则表达式
- php - PHP 字符串扩展
- postgresql - Postgres 触发器和生产者(关系的“新”列不存在)
- php - 在 PHP 中向 yandex api 发送请求时如何修复 {"code":415,"message":"Unsupported media type"}?
- javascript - 如何为数组中的每个项目运行函数或在 Mongoose 上单独编写数组对象