From 014f459b0026873b6017a87cf377c6b02d6ed773 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 1 Dec 2012 19:35:20 +0100 Subject: [PATCH] added some missing test for Template::getAttribute() --- test/Twig/Tests/TemplateTest.php | 39 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/test/Twig/Tests/TemplateTest.php b/test/Twig/Tests/TemplateTest.php index 4009607..2a9768a 100644 --- a/test/Twig/Tests/TemplateTest.php +++ b/test/Twig/Tests/TemplateTest.php @@ -106,6 +106,30 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase } /** + * @dataProvider getGetAttributeWithTemplateAsObject + */ + public function testGetAttributeWithTemplateAsObject($useExt) + { + $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); + $template1 = new Twig_TemplateTest(new Twig_Environment(), false); + + $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string')); + $this->assertEquals('some_string', $template->getAttribute($template1, 'string')); + $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'true')); + $this->assertEquals('1', $template->getAttribute($template1, 'true')); + $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty')); + $this->assertSame('', $template->getAttribute($template1, 'empty')); + } + + public function getGetAttributeWithTemplateAsObject() + { + return array( + array(false), + array(true), + ); + } + + /** * @dataProvider getGetAttributeTests */ public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false) @@ -289,6 +313,21 @@ class Twig_TemplateTest extends Twig_Template Twig_Template::clearCache(); } + public function getEmpty() + { + return ''; + } + + public function getString() + { + return 'some_string'; + } + + public function getTrue() + { + return true; + } + public function getTemplateName() { } -- 1.7.2.5