2 small fixes for unit tests

This commit is contained in:
Simon Wisselink
2023-01-07 23:45:59 +01:00
parent e1d395e140
commit 861aafa92c
2 changed files with 33 additions and 38 deletions

View File

@@ -31,14 +31,8 @@ class FunctionTest extends PHPUnit_Smarty
public function testUnknownFunction()
{
$this->smarty->enableSecurity();
try {
$this->expectException(\Smarty\CompilerException::class);
$this->expectExceptionMessage('Cannot compile unknown function unknown');
$this->smarty->fetch('eval:{unknown()}');
}
catch (Exception $e) {
$this->assertStringContainsString("PHP function 'unknown' not allowed by security setting", $e->getMessage());
return;
}
$this->fail('Exception for unknown function has not been raised.');
}
}

View File

@@ -62,9 +62,10 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedModifier()
{
$this->smarty->security_policy->disabled_modifiers[] = 'escape';
$this->expectException(\Smarty\Exception::class);
$this->expectExceptionMessage('modifier \'sizeof\' not allowed by security setting');
@$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@sizeof}');
$this->expectExceptionMessage('modifier \'escape\' disabled by security setting');
@$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|escape}');
}
/**