mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
added some missing test for Template::getAttribute()
This commit is contained in:
@@ -105,6 +105,30 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user