ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
GetAttrTest.php
Go to the documentation of this file.
1
<?php
2
3
/*
4
* This file is part of Twig.
5
*
6
* (c) Fabien Potencier
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
12
class
Twig_Tests_Node_Expression_GetAttrTest
extends
Twig_Test_NodeTestCase
13
{
14
public
function
testConstructor
()
15
{
16
$expr =
new
Twig_Node_Expression_Name
(
'foo'
, 1);
17
$attr =
new
Twig_Node_Expression_Constant
(
'bar'
, 1);
18
$args =
new
Twig_Node_Expression_Array
(
array
(), 1);
19
$args->addElement(
new
Twig_Node_Expression_Name
(
'foo'
, 1));
20
$args->addElement(
new
Twig_Node_Expression_Constant
(
'bar'
, 1));
21
$node =
new
Twig_Node_Expression_GetAttr
($expr, $attr, $args,
Twig_Template::ARRAY_CALL
, 1);
22
23
$this->assertEquals($expr, $node->getNode(
'node'
));
24
$this->assertEquals($attr, $node->getNode(
'attribute'
));
25
$this->assertEquals($args, $node->getNode(
'arguments'
));
26
$this->assertEquals(
Twig_Template::ARRAY_CALL
, $node->getAttribute(
'type'
));
27
}
28
29
public
function
getTests
()
30
{
31
$tests =
array
();
32
33
$expr =
new
Twig_Node_Expression_Name
(
'foo'
, 1);
34
$attr =
new
Twig_Node_Expression_Constant
(
'bar'
, 1);
35
$args =
new
Twig_Node_Expression_Array
(
array
(), 1);
36
$node =
new
Twig_Node_Expression_GetAttr
($expr, $attr, $args,
Twig_Template::ANY_CALL
, 1);
37
$tests[] =
array
($node, sprintf(
'%s%s, "bar", array())'
, $this->
getAttributeGetter
(), $this->
getVariableGetter
(
'foo'
, 1)));
38
39
$node =
new
Twig_Node_Expression_GetAttr
($expr, $attr, $args,
Twig_Template::ARRAY_CALL
, 1);
40
$tests[] =
array
($node, sprintf(
'%s%s, "bar", array(), "array")'
, $this->
getAttributeGetter
(), $this->
getVariableGetter
(
'foo'
, 1)));
41
42
$args =
new
Twig_Node_Expression_Array
(
array
(), 1);
43
$args->addElement(
new
Twig_Node_Expression_Name
(
'foo'
, 1));
44
$args->addElement(
new
Twig_Node_Expression_Constant
(
'bar'
, 1));
45
$node =
new
Twig_Node_Expression_GetAttr
($expr, $attr, $args,
Twig_Template::METHOD_CALL
, 1);
46
$tests[] =
array
($node, sprintf(
'%s%s, "bar", array(0 => %s, 1 => "bar"), "method")'
, $this->
getAttributeGetter
(), $this->
getVariableGetter
(
'foo'
, 1), $this->
getVariableGetter
(
'foo'
)));
47
48
return
$tests;
49
}
50
}
Twig_Node_Expression_Name
Definition:
Name.php:12
Twig_Tests_Node_Expression_GetAttrTest
Definition:
GetAttrTest.php:12
Twig_Test_NodeTestCase
Definition:
NodeTestCase.php:14
Twig_Node_Expression_Array
Definition:
Array.php:11
Twig_TemplateInterface\METHOD_CALL
const METHOD_CALL
Definition:
TemplateInterface.php:23
Twig_Test_NodeTestCase\getAttributeGetter
getAttributeGetter()
Definition:
NodeTestCase.php:63
Twig_Node_Expression_GetAttr
Definition:
GetAttr.php:12
array
Create styles array
The data for the language used.
Definition:
40duplicateStyle.php:19
Twig_Node_Expression_Constant
Definition:
Constant.php:12
Twig_Test_NodeTestCase\getVariableGetter
getVariableGetter($name, $line=false)
Definition:
NodeTestCase.php:48
Twig_TemplateInterface\ARRAY_CALL
const ARRAY_CALL
Definition:
TemplateInterface.php:22
Twig_TemplateInterface\ANY_CALL
const ANY_CALL
Definition:
TemplateInterface.php:21
Twig_Tests_Node_Expression_GetAttrTest\testConstructor
testConstructor()
Definition:
GetAttrTest.php:14
Twig_Tests_Node_Expression_GetAttrTest\getTests
getTests()
Definition:
GetAttrTest.php:29
libs
composer
vendor
twig
twig
test
Twig
Tests
Node
Expression
GetAttrTest.php
Generated on Sat Jan 18 2025 19:01:13 for ILIAS by
1.8.13 (using
Doxyfile
)