Skip to content

Commit

Permalink
Update block extends tests #393
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Oct 12, 2017
1 parent df97b8a commit f41afe3
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public function testNotExistingChildBlock_024()

/**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage tag {$smarty.block.child} used outside {block} tags
* @expectedExceptionMessage "$smarty.block.child" used outside {block} tags
* test {$this->smarty.block.child} outside {block]
*/
public function testSmartyBlockChildOutsideBlock_025()
Expand All @@ -762,7 +762,7 @@ public function testSmartyBlockChildOutsideBlock_025()

/**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage tag {$smarty.block.parent} used outside {block} tags
* @expectedExceptionMessage "$smarty.block.parent" used outside {block} tags
* test {$this->smarty.block.parent} outside {block]
*/
public function testSmartyBlockParentOutsideBlock_026()
Expand All @@ -772,7 +772,7 @@ public function testSmartyBlockParentOutsideBlock_026()

/**
* @expectedException SmartyException
* @expectedExceptionMessage illegal {$smarty.block.parent}
* @expectedExceptionMessage illegal '$smarty.block.parent'
* test {$this->smarty.block.parent} in parent template
*/
public function testSmartyBlockParentInParent_027()
Expand Down Expand Up @@ -858,7 +858,7 @@ public function testCompileBlockGrandChildNested_030($caching, $merge, $testNumb
* @dataProvider data
*/
public function testCompileBlockGrandChildNestedRelative_030($caching, $merge, $testNumber, $compileTestNumber,
$renderTestNumber, $testName)
$renderTestNumber, $testName)
{
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
$this->smarty->assign('test', $testNumber);
Expand All @@ -873,6 +873,54 @@ public function testCompileBlockGrandChildNestedRelative_030($caching, $merge, $
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}
/**
* test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache}
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider data
*/
public function testCompileBlockSmartyBlockParent_034($caching, $merge, $testNumber, $compileTestNumber,
$renderTestNumber, $testName)
{
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
$this->smarty->assign('test', $testNumber);
$this->smarty->setCaching($caching);
$this->smarty->setMergeCompiledIncludes($merge);
if ($merge) {
$this->smarty->setCompileId(1);
}
$result = $this->smarty->fetch('034_child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}
/**
* test child/parent template chain with {$this->smarty.block.child)
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider data
*/
public function testCompileBlockSmartyBlockChild_035($caching, $merge, $testNumber, $compileTestNumber,
$renderTestNumber, $testName)
{
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
$this->smarty->assign('test', $testNumber);
$this->smarty->assign('parent', 'parent', true);
$this->smarty->assign('child', 'child', true);
$this->smarty->setCaching($caching);
$this->smarty->setMergeCompiledIncludes($merge);
if ($merge) {
$this->smarty->setCompileId(1);
}
$result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}


public function data()
{
Expand Down Expand Up @@ -945,5 +993,28 @@ public function testCompileBlockRelativeIncludes_033($caching, $merge, $testNumb
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure');
}
/**
*
* test smarty.block.foo
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage invalid "$smarty.block.foo" expected "$smarty.block.child" or "$smarty.block.parent"
*/
public function testSmartyBlockWrongBlockName_036()
{
$this->smarty->fetch('036_parent.tpl');
}

/**
*
* test smarty.block
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage invalid "$smarty.block" expected "$smarty.block.child" or "$smarty.block.parent"
*/
public function testSmartyBlockMissigBlockName_037()
{
$this->smarty->fetch('037_parent.tpl');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{extends '034_parent.tpl'}
{block 'b1'}{$foo=$smarty.block.parent}{$foo}{/block}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:{$test nocache} compiled:# rendered:{$test}
{block 'b1'}parent b1{/block}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{extends file='035_parent.tpl'}
{block name='b'}(child|b)content {$child} b(child|/b){/block}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:{$test nocache} compiled:# rendered:{$test}
{block name='b'}(parent|b)content {$foo=$smarty.block.child}{$foo} b(parent|/b){/block}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{block name='b'}{$smarty.block.foo}{/block}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{block name='b'}{$smarty.block}{/block}

0 comments on commit f41afe3

Please sign in to comment.