mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/9701] Prevent notices from being hidden by template tests
The template tests disable NOTICEs for the duration of template execution since the current version of the template engine does not generate sufficiently clean code. The error level is reset aftwards, however that part is skipped when trigger_error is called which is converted into a regular exception by PHPUnit and passed down until caught. Such exceptions are now caught to reset the error level, and then the exception is rethrown. This uncovered another issue in the template tests which only passed because NOTICEs were unintentionally disabled at this point. assign_display is also required to operate without NOTICEs. The respective code has been added around its callee as well. However no handling of exceptions takes place there. If another test checking for errors in that function is ever added similar catch logic will have to be added there. PHPBB3-9701
This commit is contained in:
parent
6da582e8be
commit
bbc3105466
1 changed files with 21 additions and 3 deletions
|
@ -26,12 +26,24 @@ class phpbb_template_template_test extends phpbb_test_case
|
||||||
error_reporting($error_level & ~E_NOTICE);
|
error_reporting($error_level & ~E_NOTICE);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
$this->assertTrue($this->template->display($handle, false));
|
$this->assertTrue($this->template->display($handle, false));
|
||||||
|
}
|
||||||
|
catch (Exception $exception)
|
||||||
|
{
|
||||||
|
// reset the error level even when an error occured
|
||||||
|
// PHPUnit turns trigger_error into exceptions as well
|
||||||
|
error_reporting($error_level);
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = self::trim_template_result(ob_get_clean());
|
||||||
|
|
||||||
// reset error level
|
// reset error level
|
||||||
error_reporting($error_level);
|
error_reporting($error_level);
|
||||||
|
return $result;
|
||||||
return self::trim_template_result(ob_get_clean());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function trim_template_result($result)
|
private static function trim_template_result($result)
|
||||||
|
@ -368,9 +380,15 @@ class phpbb_template_template_test extends phpbb_test_case
|
||||||
$this->template->destroy_block_vars($block);
|
$this->template->destroy_block_vars($block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$error_level = error_reporting();
|
||||||
|
error_reporting($error_level & ~E_NOTICE);
|
||||||
|
|
||||||
$this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
|
$this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
|
||||||
|
|
||||||
$this->template->assign_display('test', 'VARIABLE', false);
|
$this->template->assign_display('test', 'VARIABLE', false);
|
||||||
|
|
||||||
|
error_reporting($error_level);
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
|
$this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue