这似乎只发生在我的系统上。没有其他人可以重现它。如果错误消息太大(在我的情况下约为65k字节),则屏幕上不会打印任何内容。我在Windows 7上使用PHP 7.1.3,默认的php.ini(内存限制设置为8gb)和默认的PHPUnit 6.0.13配置。错误不会出现在prompt和powershell中。
<?php
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\TestCase;
class MyConstraint extends Constraint
{
protected $expected;
function __construct($expected){
parent::__construct();
$this->expected = $expected;
}
protected function matches($actual){
return false;
}
function failureDescription($other): string{
return "desc";
}
function toString(){
return "description";
}
function additionalFailureDescription($other): string{
return str_repeat("x", 100000);
// If set to a smaller dump, error will appear
// some people I asked to try could dump one million
// bytes without problems, while I can't print more
// than about 50k
}
}
class SomeTest extends TestCase
{
function testBigDump(){
TestCase::assertThat("irrelevant", new MyConstraint("irrelevant"));
}
}
?>
这就是我在屏幕上看到的内容:
Sebastian Bergmann和贡献者的PHPUnit 6.0.13。
运行时:PHPDBG 7.1.3配置:..............
F 1/1(100%)
时间:361毫秒,内存:6.00MB
有1次失败:
1)SomeTest :: testBigDump
<------- Notice no error description here
FAILURES!测试:1,断言:1,失败:1。
你知道是什么原因引起的吗?提前谢谢。
答案 0 :(得分:9)
您的配置中的某些内容正在通过phpdbg运行phpunit测试
我重新创建了此问题,尝试使用Windows 7 VM尽可能多地复制环境。
线索是转储中的Runtime: PHPDBG
行。显然有关phpdbg运行时的东西会阻止大缓冲区正常工作。请参阅下面的输出,通过phpdbg.exe运行时的初始输出(缺少测试说明),然后通过php.exe运行(显然是截断的):
C:\project>phpdbg -r phpunit-6.1.0.phar -v test.php
[Welcome to phpdbg, the interactive PHP debugger, v0.5.0]
To get help using phpdbg type "help" and press enter
[Please report bugs to <http://bugs.php.net/report.php>]
PHPUnit 6.1.0 by Sebastian Bergmann and contributors.
Runtime: PHPDBG 7.1.4
F 1 / 1 (100%)
Time: 99 ms, Memory: 22.00MB
There was 1 failure:
1) SomeTest::testBigDump
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
[Script ended normally]
C:\project>php phpunit-6.1.0.phar test.php
PHPUnit 6.1.0 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 109 ms, Memory: 8.00MB
There was 1 failure:
1) SomeTest::testBigDump
Failed asserting that desc.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----- Snip -----