mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Develop
This commit is contained in:
@@ -1,21 +1,58 @@
|
||||
<?php
|
||||
namespace Aspect\Template;
|
||||
namespace Aspect;
|
||||
use Aspect, Aspect\Modifier, Aspect\TestCase;
|
||||
|
||||
class ExtendsTest extends TestCase {
|
||||
class ExtendsTemplateTest extends TestCase {
|
||||
public static function providerExtends() {
|
||||
$a = array("one" => 1, "two" => 2, "three" => 3);
|
||||
return array(
|
||||
array('{extends "parent.tpl"}{block "bk1"} block1 {/block}', "Template extended by block1"),
|
||||
array('{extends "parent.tpl"}{block "bk1"} block1 {/block}{block "bk2"} block2 {/block} garbage', "Template extended by block1"),
|
||||
array('{extends "parent.tpl"}{block "bk1"} block1 {/block}{block "bk2"} block2 {/block} {block "bk3"} block3 {/block} garbage', "Template multi-extended by block1"),
|
||||
array('{extends "parent.tpl"}{var $bk = "bk3"}{block "bk1"} block1 {/block}{block "bk2"} block2 {/block} {block "$bk"} block3 {/block} garbage', "Template multi-extended by block1"),
|
||||
array("parent.tpl", "Parent. B1: {block b1}{/block}\nB2: {block 'b2'}empty {\$iteration}{/block}", $a,
|
||||
"Parent. B1: \nB2: empty 0"),
|
||||
array("child1.tpl", '{extends "parent.tpl"} {block b1}from child1 {$iteration}{/block} some trash', $a,
|
||||
"Parent. B1: from child1 1\nB2: empty 1"),
|
||||
array("child2.tpl", '{extends "child1.tpl"} {block "b2"}from child2 {$iteration}{/block} some {block b4}what is it?{/block} trash', $a,
|
||||
"Parent. B1: from child1 2\nB2: from child2 2"),
|
||||
array("child3.tpl", '{extends "child2.tpl"} {block \'b1\'}from child3 {$iteration}{/block} {block "b2"}from child3 {$iteration}{/block} some {block b4}what is it?{/block} trash', $a,
|
||||
"Parent. B1: from child3 3\nB2: from child3 3")
|
||||
);
|
||||
}
|
||||
|
||||
public static function providerDynamicExtends() {
|
||||
$data = self::providerExtends();
|
||||
$data[2][1] = str_replace('"b2"', '"b{$two}"', $data[2][1]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerExtends
|
||||
* @param $name
|
||||
* @param $code
|
||||
* @param $vars
|
||||
* @param $result
|
||||
*/
|
||||
public function _testStaticExtends($name, $code, $vars, $result) {
|
||||
static $i = 0;
|
||||
$vars["iteration"] = $i++;
|
||||
$this->execTpl($name, $code, $vars, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDynamicExtends
|
||||
* @param $name
|
||||
* @param $code
|
||||
* @param $vars
|
||||
* @param $result
|
||||
*/
|
||||
public function testDynamicExtends($name, $code, $vars, $result) {
|
||||
static $i = 0;
|
||||
$vars["iteration"] = $i++;
|
||||
$this->execTpl($name, $code, $vars, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group extends
|
||||
*/
|
||||
public function testParentLevel() {
|
||||
public function _testParentLevel() {
|
||||
//echo($this->aspect->getTemplate("parent.tpl")->_body); exit;
|
||||
$this->assertSame($this->aspect->fetch("parent.tpl", array("a" => "a char")), "Parent template\nBlock1: Block2: Block3: default");
|
||||
}
|
||||
@@ -23,7 +60,7 @@ class ExtendsTest extends TestCase {
|
||||
/**
|
||||
* @group extends
|
||||
*/
|
||||
public function testChildLevel1() {
|
||||
public function _testChildLevel1() {
|
||||
//echo($this->aspect->fetch("child1.tpl", array("a" => "a char"))); exit;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user