mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Merge remote-tracking branch 'cyberalien/ticket/10350' into develop
* cyberalien/ticket/10350: [ticket/10350] Script for testing eval renderer [ticket/10350] Fix for class phpbb_template_renderer_eval
This commit is contained in:
commit
367fe0b4cf
2 changed files with 32 additions and 1 deletions
|
@ -55,6 +55,6 @@ class phpbb_template_renderer_eval implements phpbb_template_renderer
|
||||||
$_rootref = &$context->get_root_ref();
|
$_rootref = &$context->get_root_ref();
|
||||||
$_lang = $lang;
|
$_lang = $lang;
|
||||||
|
|
||||||
eval($this->code);
|
eval(' ?>' . $this->code . '<?php ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
tests/template/renderer_eval_test.php
Normal file
31
tests/template/renderer_eval_test.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_template_renderer_eval_test extends phpbb_test_case
|
||||||
|
{
|
||||||
|
public function test_eval()
|
||||||
|
{
|
||||||
|
$compiled_code = '<a href="<?php echo \'Test\'; ?>">';
|
||||||
|
$valid_code = '<a href="Test">';
|
||||||
|
$context = new phpbb_template_context();
|
||||||
|
$template = new phpbb_template_renderer_eval($compiled_code, NULL);
|
||||||
|
ob_start();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$template->render($context, array());
|
||||||
|
}
|
||||||
|
catch (Exception $exception)
|
||||||
|
{
|
||||||
|
ob_end_clean();
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
$output = ob_get_clean();
|
||||||
|
$this->assertEquals($valid_code, $output);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue