* Output file headers to initialise the download of the file.
*/
public function send_http_headers() {
- if (defined('BEHAT_SITE_RUNNING')) {
+ if (defined('BEHAT_SITE_RUNNING') || PHPUNIT_TEST) {
// For text based formats - we cannot test the output with behat if we force a file download.
return;
}
$this->writer->setTempFolder(make_request_directory());
}
$filename = $this->filename . $this->get_extension();
- $this->writer->openToBrowser($filename);
+ if (PHPUNIT_TEST) {
+ $this->writer->openToFile('php://output');
+ } else {
+ $this->writer->openToBrowser($filename);
+ }
// By default one sheet is always created, but we want to rename it when we call start_sheet().
$this->renamecurrentsheet = true;