芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/fmd/vendor/twig/twig/test/Twig/Tests/TemplateWrapperTest.php
'{% block foo %}{% endblock %}', 'index_with_use' => '{% use "imported" %}{% block foo %}{% endblock %}', 'index_with_extends' => '{% extends "extended" %}{% block foo %}{% endblock %}', 'imported' => '{% block imported %}{% endblock %}', 'extended' => '{% block extended %}{% endblock %}', ))); $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); $this->assertTrue($wrapper->hasBlock('foo')); $this->assertFalse($wrapper->hasBlock('bar')); $this->assertEquals(array('foo'), $wrapper->getBlockNames()); $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_use')); $this->assertTrue($wrapper->hasBlock('foo')); $this->assertTrue($wrapper->hasBlock('imported')); $this->assertEquals(array('imported', 'foo'), $wrapper->getBlockNames()); $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_extends')); $this->assertTrue($wrapper->hasBlock('foo')); $this->assertTrue($wrapper->hasBlock('extended')); $this->assertEquals(array('foo', 'extended'), $wrapper->getBlockNames()); } public function testRenderBlock() { $twig = new Twig_Environment(new Twig_Loader_Array(array( 'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}', ))); $twig->addGlobal('bar', 'BAR'); $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); $this->assertEquals('FOOBAR', $wrapper->renderBlock('foo', array('foo' => 'FOO'))); } public function testDisplayBlock() { $twig = new Twig_Environment(new Twig_Loader_Array(array( 'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}', ))); $twig->addGlobal('bar', 'BAR'); $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); ob_start(); $wrapper->displayBlock('foo', array('foo' => 'FOO')); $this->assertEquals('FOOBAR', ob_get_clean()); } }