针对致命错误的PHPUnit集成测试:已耗尽允许的内存大小
我想测试我的应用程序是否记录了致命错误针对致命错误的PHPUnit集成测试:已耗尽允许的内存大小,phpunit,php-7,monolog,Phpunit,Php 7,Monolog,我想测试我的应用程序是否记录了致命错误 PHP Fatal error: Allowed memory size exhausted 到我的独白处理程序文件。我想为此编写一个集成测试。 问题是,当我触发错误时,PHPUnit将停止 /** * @return void */ public function testMemoryLimitExhaustedLogToMonolog(): void { // set memory limit 100mb ini_set('me
PHP Fatal error: Allowed memory size exhausted
到我的独白处理程序文件。我想为此编写一个集成测试。
问题是,当我触发错误时,PHPUnit将停止
/**
* @return void
*/
public function testMemoryLimitExhaustedLogToMonolog(): void
{
// set memory limit 100mb
ini_set('memory_limit', '100M');
while(true) {
$memoryExhaustingArray[] = 1;
}
$this->assertThatMyLogFileHasCatchedTheOutOfMemoryException();
}
有没有办法测试PHP7中的致命内存不足错误?我认为,没有办法测试这个致命错误,因为PHPUnit在内存不足时崩溃。此错误触发脚本终止,无法捕获: