mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix #256
This commit is contained in:
parent
35455b761f
commit
d139a1ebf3
@ -237,7 +237,7 @@ class Tag extends \ArrayObject
|
|||||||
*/
|
*/
|
||||||
public function cutContent()
|
public function cutContent()
|
||||||
{
|
{
|
||||||
$content = substr($this->_body, $this->_offset + 1);
|
$content = substr($this->_body, $this->_offset);
|
||||||
$this->_body = substr($this->_body, 0, $this->_offset);
|
$this->_body = substr($this->_body, 0, $this->_offset);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
@ -788,38 +788,6 @@ class TemplateTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providerSwitch()
|
|
||||||
{
|
|
||||||
$code1 = 'Switch: {switch $a}
|
|
||||||
{case 1, "one"} one
|
|
||||||
{case 2, "two"} two
|
|
||||||
{case "string", default} str
|
|
||||||
{default} def
|
|
||||||
{/switch} end';
|
|
||||||
|
|
||||||
$code2 = 'Switch: {switch $a}
|
|
||||||
{case 1, "one"} one
|
|
||||||
{case 2, "two"} two
|
|
||||||
{case "string"} str
|
|
||||||
{/switch} end';
|
|
||||||
|
|
||||||
$code3 = 'Switch: {switch $a} invalid
|
|
||||||
{case 1, "one"} one
|
|
||||||
{/switch} end';
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array($code1, array("a" => 1), 'Switch: one end'),
|
|
||||||
array($code1, array("a" => 'one'), 'Switch: one end'),
|
|
||||||
array($code1, array("a" => 2), 'Switch: two end'),
|
|
||||||
array($code1, array("a" => 'two'), 'Switch: two end'),
|
|
||||||
array($code1, array("a" => "string"), 'Switch: str end'),
|
|
||||||
array($code1, array("a" => "unk"), 'Switch: str def end'),
|
|
||||||
array($code2, array("a" => "unk"), 'Switch: end'),
|
|
||||||
array($code3, array("a" => 1), 'Switch: one end'),
|
|
||||||
array($code3, array("a" => 'one'), 'Switch: one end'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function providerSwitchInvalid()
|
public static function providerSwitchInvalid()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
@ -1474,6 +1442,44 @@ class TemplateTest extends TestCase
|
|||||||
$this->exec($code, $vars, $result);
|
$this->exec($code, $vars, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function providerSwitch()
|
||||||
|
{
|
||||||
|
$code1 = 'Switch: {switch $a}
|
||||||
|
{case 1, "one"} one
|
||||||
|
{case 2, "two"} two
|
||||||
|
{case "string", default} str
|
||||||
|
{default} def
|
||||||
|
{/switch} end';
|
||||||
|
|
||||||
|
$code2 = 'Switch: {switch $a}
|
||||||
|
{case 1, "one"} one
|
||||||
|
{case 2, "two"} two
|
||||||
|
{case "string"} str
|
||||||
|
{/switch} end';
|
||||||
|
|
||||||
|
$code3 = 'Switch: {switch $a} invalid
|
||||||
|
{case 1, "one"} one
|
||||||
|
{/switch} end';
|
||||||
|
|
||||||
|
$code4 = 'Switch:{switch $a}{case 1}<b>one</b>{/switch}end';
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array($code1, array("a" => 1), 'Switch: one end'),
|
||||||
|
array($code1, array("a" => 'one'), 'Switch: one end'),
|
||||||
|
array($code1, array("a" => 2), 'Switch: two end'),
|
||||||
|
array($code1, array("a" => 'two'), 'Switch: two end'),
|
||||||
|
array($code1, array("a" => "string"), 'Switch: str end'),
|
||||||
|
array($code1, array("a" => "unk"), 'Switch: str def end'),
|
||||||
|
array($code2, array("a" => "unk"), 'Switch: end'),
|
||||||
|
array($code3, array("a" => 1), 'Switch: one end'),
|
||||||
|
array($code3, array("a" => 'one'), 'Switch: one end'),
|
||||||
|
array($code4, array("a" => 1), 'Switch:<b>one</b>end'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group switch
|
* @group switch
|
||||||
* @dataProvider providerSwitch
|
* @dataProvider providerSwitch
|
||||||
|
Loading…
Reference in New Issue
Block a user