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:
@@ -29,8 +29,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException SmartyException
|
* @expectedException SmartyException
|
||||||
* @expectedExceptionMessage Unable to read
|
* @expectedExceptionMessage Unable to load config 'file:foo.conf'
|
||||||
* @expectedExceptionMessage file 'foo.conf'
|
|
||||||
*
|
*
|
||||||
* test unknown config file
|
* test unknown config file
|
||||||
*/
|
*/
|
||||||
@@ -80,8 +79,21 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException SmartyException
|
* @expectedException SmartyException
|
||||||
* @expectedExceptionMessage Unable to read
|
* @expectedExceptionMessage Unable to load config default file 'no.conf' for 'file:fo.conf'
|
||||||
* @expectedExceptionMessage file 'foo.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)
|
* test default config handler replacement (return false)
|
||||||
*
|
*
|
||||||
@@ -90,6 +102,21 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$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)
|
function configHandlerData($resource_type, $resource_name, &$config_source, &$config_timestamp, Smarty $smarty)
|
||||||
{
|
{
|
||||||
|
if ($resource_name !== 'foo.conf') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$output = "foo = 'bar'\n";
|
$output = "foo = 'bar'\n";
|
||||||
$config_source = $output;
|
$config_source = $output;
|
||||||
$config_timestamp = time();
|
$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)
|
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';
|
return $smarty->getConfigDir(0) . 'test.conf';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->fetch('foo.tpl');
|
$this->smarty->fetch('foo.tpl');
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user