mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
Update default handler teste
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* class for default config handler test
|
||||
*
|
||||
* @runTestsInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @preserveGlobalState disabled
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
||||
@@ -29,8 +29,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
||||
|
||||
/**
|
||||
* @expectedException SmartyException
|
||||
* @expectedExceptionMessage Unable to read
|
||||
* @expectedExceptionMessage file 'foo.conf'
|
||||
* @expectedExceptionMessage Unable to load config 'file:foo.conf'
|
||||
*
|
||||
* test unknown config file
|
||||
*/
|
||||
@@ -80,16 +79,44 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
||||
|
||||
/**
|
||||
* @expectedException SmartyException
|
||||
* @expectedExceptionMessage Unable to read
|
||||
* @expectedExceptionMessage file 'foo.conf'
|
||||
* @expectedExceptionMessage Unable to load config default file 'no.conf' for 'file:fo.conf'
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function testDefaultConfigHandlerReplacementByConfigFileFail()
|
||||
{
|
||||
$this->smarty->registerDefaultConfigHandler('configHandlerFile');
|
||||
$this->smarty->configLoad('fo.conf');
|
||||
$this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SmartyException
|
||||
* @expectedExceptionMessage Unable to load config 'file:foo.conf'
|
||||
*
|
||||
*
|
||||
* test default config handler replacement (return false)
|
||||
*
|
||||
*/
|
||||
public function testDefaultConfigHandlerReplacementReturningFalse()
|
||||
{
|
||||
$this->smarty->configLoad('foo.conf');
|
||||
$this->smarty->configLoad('foo.conf');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException SmartyException
|
||||
* @expectedExceptionMessage No config default content for 'file:bla.conf'
|
||||
*
|
||||
*
|
||||
* test default config handler replacement (return false)
|
||||
*
|
||||
*/
|
||||
public function testDefaultConfigHandlerReplacementReturningFalse1()
|
||||
{
|
||||
$this->smarty->registerDefaultConfigHandler('configHandlerData');
|
||||
$this->smarty->configLoad('bla.conf');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +132,9 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
||||
*/
|
||||
function configHandlerData($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty)
|
||||
{
|
||||
if ($resource_name !== 'foo.conf') {
|
||||
return false;
|
||||
}
|
||||
$output = "foo = 'bar'\n";
|
||||
$config_source = $output;
|
||||
$config_timestamp = time();
|
||||
@@ -125,6 +155,10 @@ function configHandlerData($resource_type, $resource_name, &$config_source, &$co
|
||||
*/
|
||||
function configHandlerFile($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty)
|
||||
{
|
||||
if ($resource_name !== 'foo.conf') {
|
||||
return 'no.conf';
|
||||
}
|
||||
|
||||
return $smarty->getConfigDir(0) . 'test.conf';
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
|
||||
$this->smarty->fetch('foo.tpl');
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->assertContains('Unable to load template', $e->getMessage());
|
||||
$this->assertContains('Default handler: No template default content for \'file:foo.tpl\'', $e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user