我想测试,如果我的应用程序记录了致命错误
PHP Fatal error: Allowed memory size exhausted
到我的独白处理程序文件。我想为此编写一个集成测试。问题是当我触发错误时,PHPUnit将停止。
/**
* @return void
*/
public function testMemoryLimitExhaustedLogToMonolog(): void
{
// set memory limit 1mb
ini_set('memory_limit', '1M');
while(true) {
$memoryExhaustingArray[] = 1;
}
$this->assertThatMyLogFileHasCatchedTheOutOfMemoryException();
}
有没有一种方法可以测试PHP7中的致命内存不足错误?
我认为,无法测试此致命错误,因为PHPUnit内存不足时会崩溃。