ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Tests_Node_Expression_TestTest Class Reference
+ Inheritance diagram for Twig_Tests_Node_Expression_TestTest:
+ Collaboration diagram for Twig_Tests_Node_Expression_TestTest:

Public Member Functions

 testConstructor ()
 
 getTests ()
 
- Public Member Functions inherited from Twig_Test_NodeTestCase
 getTests ()
 
 testCompile ($node, $source, $environment=null, $isPattern=false)
 getTests More...
 
 assertNodeCompilation ($source, Twig_Node $node, Twig_Environment $environment=null, $isPattern=false)
 

Protected Member Functions

 createTest ($node, $name, array $arguments=array())
 
 getEnvironment ()
 
- Protected Member Functions inherited from Twig_Test_NodeTestCase
 getCompiler (Twig_Environment $environment=null)
 
 getEnvironment ()
 
 getVariableGetter ($name, $line=false)
 
 getAttributeGetter ()
 

Detailed Description

Definition at line 12 of file TestTest.php.

Member Function Documentation

◆ createTest()

Twig_Tests_Node_Expression_TestTest::createTest (   $node,
  $name,
array  $arguments = array() 
)
protected

Definition at line 65 of file TestTest.php.

References $name.

Referenced by getTests().

66  {
67  return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1);
68  }
Represents a node in the AST.
Definition: Node.php:18
if($format !==null) $name
Definition: metadata.php:146
+ Here is the caller graph for this function:

◆ getEnvironment()

Twig_Tests_Node_Expression_TestTest::getEnvironment ( )
protected

Definition at line 70 of file TestTest.php.

71  {
72  if (PHP_VERSION_ID >= 50300) {
73  return include 'PHP53/TestInclude.php';
74  }
75 
76  return parent::getEnvironment();
77  }

◆ getTests()

Twig_Tests_Node_Expression_TestTest::getTests ( )

Definition at line 26 of file TestTest.php.

References array, and createTest().

27  {
28  $environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
29  $environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true)));
30 
31  $tests = array();
32 
33  $expr = new Twig_Node_Expression_Constant('foo', 1);
34  $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 1);
35  $tests[] = array($node, '(null === "foo")');
36 
37  // test as an anonymous function
38  if (PHP_VERSION_ID >= 50300) {
39  $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
40  $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))');
41  }
42 
43  // arbitrary named arguments
44  $string = new Twig_Node_Expression_Constant('abc', 1);
45  $node = $this->createTest($string, 'barbar');
46  $tests[] = array($node, 'twig_tests_test_barbar("abc")', $environment);
47 
48  $node = $this->createTest($string, 'barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1)));
49  $tests[] = array($node, 'twig_tests_test_barbar("abc", null, null, array("foo" => "bar"))', $environment);
50 
51  $node = $this->createTest($string, 'barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1)));
52  $tests[] = array($node, 'twig_tests_test_barbar("abc", null, "bar")', $environment);
53 
54  $node = $this->createTest($string, 'barbar', array(
58  'foo' => new Twig_Node_Expression_Constant('bar', 1),
59  ));
60  $tests[] = array($node, 'twig_tests_test_barbar("abc", "1", "2", array(0 => "3", "foo" => "bar"))', $environment);
61 
62  return $tests;
63  }
Represents a node in the AST.
Definition: Node.php:18
createTest($node, $name, array $arguments=array())
Definition: TestTest.php:65
Checks that a variable is null.
Definition: Null.php:21
Create styles array
The data for the language used.
Represents a template test.
Definition: SimpleTest.php:19
Stores the Twig configuration.
Definition: Environment.php:17
+ Here is the call graph for this function:

◆ testConstructor()

Twig_Tests_Node_Expression_TestTest::testConstructor ( )

Definition at line 14 of file TestTest.php.

References $name.

15  {
16  $expr = new Twig_Node_Expression_Constant('foo', 1);
17  $name = new Twig_Node_Expression_Constant('null', 1);
18  $args = new Twig_Node();
19  $node = new Twig_Node_Expression_Test($expr, $name, $args, 1);
20 
21  $this->assertEquals($expr, $node->getNode('node'));
22  $this->assertEquals($args, $node->getNode('arguments'));
23  $this->assertEquals($name, $node->getAttribute('name'));
24  }
Represents a node in the AST.
Definition: Node.php:18
if($format !==null) $name
Definition: metadata.php:146

The documentation for this class was generated from the following file: