问题描述
我想知道是否有可能防止这种情况发生(在这种情况下,仅通过测试请参见.
;如果可能的话,最好不要进行risky
测试)。将此特定测试的内容添加到输出中没有任何意义。
我尝试了几件事,但没有达到预期的结果:
-
--disallow-test-output
已添加到CLI命令 -
beStrictAboutCoversAnnotation="true"
在PHPUnit XML配置中 -
ob_get_clean()
而非flush
(如here所述)
Class 方法
public function download()
{
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename="' . basename(<path-to-file>) . '"');
header('Content-Length: ' . filesize(<path-to-file>));
flush();
readfile($archivePath);
}
测试:
({$this->SUT
指上述类)
public function testItDeletesZipArchiveAfterDownload()
{
$this->SUT->download();
$this->assertFileNotExists(<path-to-file>);
}
谢谢您的反馈。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)