Version 1
[yaffs-website] / vendor / symfony / expression-language / Tests / Node / ArrayNodeTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 namespace Symfony\Component\ExpressionLanguage\Tests\Node;
13
14 use Symfony\Component\ExpressionLanguage\Node\ArrayNode;
15 use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
16
17 class ArrayNodeTest extends AbstractNodeTest
18 {
19     public function testSerialization()
20     {
21         $node = $this->createArrayNode();
22         $node->addElement(new ConstantNode('foo'));
23
24         $serializedNode = serialize($node);
25         $unserializedNode = unserialize($serializedNode);
26
27         $this->assertEquals($node, $unserializedNode);
28         $this->assertNotEquals($this->createArrayNode(), $unserializedNode);
29     }
30
31     public function getEvaluateData()
32     {
33         return array(
34             array(array('b' => 'a', 'b'), $this->getArrayNode()),
35         );
36     }
37
38     public function getCompileData()
39     {
40         return array(
41             array('array("b" => "a", 0 => "b")', $this->getArrayNode()),
42         );
43     }
44
45     protected function getArrayNode()
46     {
47         $array = $this->createArrayNode();
48         $array->addElement(new ConstantNode('a'), new ConstantNode('b'));
49         $array->addElement(new ConstantNode('b'));
50
51         return $array;
52     }
53
54     protected function createArrayNode()
55     {
56         return new ArrayNode();
57     }
58 }