2020-04-13 15:30:52 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Smarty PHPunit tests of function calls
|
|
|
|
|
*
|
2023-01-05 23:06:02 +01:00
|
|
|
|
2020-04-13 15:30:52 +02:00
|
|
|
* @author Uwe Tews
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* class for function tests
|
|
|
|
|
*
|
2023-01-05 23:06:02 +01:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
2020-04-13 15:30:52 +02:00
|
|
|
*/
|
|
|
|
|
class FunctionTest extends PHPUnit_Smarty
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
public function setUp(): void
|
2020-04-13 15:30:52 +02:00
|
|
|
{
|
2022-09-27 13:03:34 +03:00
|
|
|
$this->setUpSmarty(__DIR__);
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInit()
|
|
|
|
|
{
|
|
|
|
|
$this->cleanDirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* test unknown function error
|
|
|
|
|
*/
|
|
|
|
|
public function testUnknownFunction()
|
|
|
|
|
{
|
|
|
|
|
$this->smarty->enableSecurity();
|
|
|
|
|
try {
|
|
|
|
|
$this->smarty->fetch('eval:{unknown()}');
|
|
|
|
|
}
|
|
|
|
|
catch (Exception $e) {
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString("PHP function 'unknown' not allowed by security setting", $e->getMessage());
|
2020-04-13 15:30:52 +02:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->fail('Exception for unknown function has not been raised.');
|
|
|
|
|
}
|
|
|
|
|
}
|