4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_Node_Expression_TestTest
extends Twig_Test_NodeTestCase
15 * @covers Twig_Node_Expression_Test::__construct
17 public function testConstructor()
19 $expr = new Twig_Node_Expression_Constant('foo', 1);
20 $name = new Twig_Node_Expression_Constant('null', 1);
21 $args = new Twig_Node();
22 $node = new Twig_Node_Expression_Test($expr, $name, $args, 1);
24 $this->assertEquals($expr, $node->getNode('node'));
25 $this->assertEquals($args, $node->getNode('arguments'));
26 $this->assertEquals($name, $node->getAttribute('name'));
30 * @covers Twig_Node_Expression_Test::compile
31 * @dataProvider getTests
33 public function testCompile($node, $source, $environment = null)
35 parent
::testCompile($node, $source, $environment);
38 public function getTests()
42 $expr = new Twig_Node_Expression_Constant('foo', 1);
43 $node = new Twig_Node_Expression_Test_Null($expr, 'null', new Twig_Node(array()), 1);
44 $tests[] = array($node, '(null === "foo")');
46 // test as an anonymous function
47 if (version_compare(phpversion(), '5.3.0', '>=')) {
48 $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1)));
49 $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))');
55 protected function createTest($node, $name, array $arguments = array())
57 return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1);
60 protected function getEnvironment()
62 if (version_compare(phpversion(), '5.3.0', '>=')) {
63 return include 'PHP53/TestInclude.php';
66 return parent
::getEnvironment();