Yaffs site version 1.1
[yaffs-website] / vendor / symfony / config / Tests / Definition / Builder / EnumNodeDefinitionTest.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\Config\Tests\Definition\Builder;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
16
17 class EnumNodeDefinitionTest extends TestCase
18 {
19     public function testWithOneValue()
20     {
21         $def = new EnumNodeDefinition('foo');
22         $def->values(array('foo'));
23
24         $node = $def->getNode();
25         $this->assertEquals(array('foo'), $node->getValues());
26     }
27
28     public function testWithOneDistinctValue()
29     {
30         $def = new EnumNodeDefinition('foo');
31         $def->values(array('foo', 'foo'));
32
33         $node = $def->getNode();
34         $this->assertEquals(array('foo'), $node->getValues());
35     }
36
37     /**
38      * @expectedException \RuntimeException
39      * @expectedExceptionMessage You must call ->values() on enum nodes.
40      */
41     public function testNoValuesPassed()
42     {
43         $def = new EnumNodeDefinition('foo');
44         $def->getNode();
45     }
46
47     /**
48      * @expectedException \InvalidArgumentException
49      * @expectedExceptionMessage ->values() must be called with at least one value.
50      */
51     public function testWithNoValues()
52     {
53         $def = new EnumNodeDefinition('foo');
54         $def->values(array());
55     }
56
57     public function testGetNode()
58     {
59         $def = new EnumNodeDefinition('foo');
60         $def->values(array('foo', 'bar'));
61
62         $node = $def->getNode();
63         $this->assertEquals(array('foo', 'bar'), $node->getValues());
64     }
65 }