これは私のシステムでのみ起こるようです。誰もそれを再現することはできません。エラーメッセージが大きすぎる場合(私の場合約65kバイト)、何も画面に表示されません。私はデフォルトのphp.ini(メモリ制限は8GBに設定されています)とデフォルトのPHPUnit 6.0.13の設定で、Windows 7でPHP 7.1.3を使用しています。プロンプトとpowershellの両方にエラーは表示されません。セバスチャン・バーグマンとコントリビュータによるPHPUnitが非常に大きなエラーメッセージを表示しない原因は何ですか?
のPHPUnit 6.0.13:
<?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")); } } ?>
は、そして、これは私が画面上に得るものです。
ランタイム:PHPDBG 7.1.3設定:..............
、F 1/1(100%)
時間:361ミリ秒、メモリ:6.00
1)SomeTest :: testBigDump
<------- Notice no error description here
FAILURES:MB
1つの失敗がありました!テスト:1、アサーション:1、失敗:1.
何が原因で起こりうるのでしょうか?前もって感謝します。ご使用の構成で
PHPメモリは大丈夫のようです。別のエラーが発生します。テストの出力をファイルにリダイレクトしようとしましたか?あなたのコマンドラインに、そのような長い文字列を表示するのに十分なメモリがない可能性があります。擬似コードの代わりに完全な実際の例を投稿すれば、他の人が擬似コードを複製しようとする場合に役立ちます。 –
これは疑似コードではありません。それだけでエラーを引き起こすのに十分です – Wes