Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Generators/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ protected function printFooter()
{
// Turn off errors so we don't get timezone warnings if people
// don't have their timezone set.
error_reporting(0);
$errorLevel = error_reporting(0);
echo 'Documentation generated on '.date('r');
echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL;
error_reporting($errorLevel);

}//end printFooter()

Expand Down
28 changes: 28 additions & 0 deletions tests/Core/Generators/HTMLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,32 @@ public function testFooter()
}//end testFooter()


/**
* Safeguard that the footer logic doesn't permanently change the error level.
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @return void
*/
public function testFooterResetsErrorReportingToOriginalSetting()
{
$expected = error_reporting();

// Set up the ruleset.
$standard = __DIR__.'/OneDocTest.xml';
$config = new ConfigDouble(["--standard=$standard"]);
$ruleset = new Ruleset($config);

// We know there will be output, but we're not interested in the output for this test.
ob_start();
$generator = new HTMLDouble($ruleset);
$generator->printRealFooter();
ob_end_clean();

$this->assertSame($expected, error_reporting());

}//end testFooterResetsErrorReportingToOriginalSetting()


}//end class
28 changes: 28 additions & 0 deletions tests/Core/Generators/MarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,32 @@ public function testFooter()
}//end testFooter()


/**
* Safeguard that the footer logic doesn't permanently change the error level.
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*
* @return void
*/
public function testFooterResetsErrorReportingToOriginalSetting()
{
$expected = error_reporting();

// Set up the ruleset.
$standard = __DIR__.'/OneDocTest.xml';
$config = new ConfigDouble(["--standard=$standard"]);
$ruleset = new Ruleset($config);

// We know there will be output, but we're not interested in the output for this test.
ob_start();
$generator = new MarkdownDouble($ruleset);
$generator->printRealFooter();
ob_end_clean();

$this->assertSame($expected, error_reporting());

}//end testFooterResetsErrorReportingToOriginalSetting()


}//end class
Loading