Yaffs site version 1.1
[yaffs-website] / vendor / symfony / config / Tests / Definition / EnumNodeTest.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;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\EnumNode;
16
17 class EnumNodeTest extends TestCase
18 {
19     public function testFinalizeValue()
20     {
21         $node = new EnumNode('foo', null, array('foo', 'bar'));
22         $this->assertSame('foo', $node->finalize('foo'));
23     }
24
25     /**
26      * @expectedException \InvalidArgumentException
27      * @expectedExceptionMessage $values must contain at least one element.
28      */
29     public function testConstructionWithNoValues()
30     {
31         new EnumNode('foo', null, array());
32     }
33
34     public function testConstructionWithOneValue()
35     {
36         $node = new EnumNode('foo', null, array('foo'));
37         $this->assertSame('foo', $node->finalize('foo'));
38     }
39
40     public function testConstructionWithOneDistinctValue()
41     {
42         $node = new EnumNode('foo', null, array('foo', 'foo'));
43         $this->assertSame('foo', $node->finalize('foo'));
44     }
45
46     /**
47      * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
48      * @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"
49      */
50     public function testFinalizeWithInvalidValue()
51     {
52         $node = new EnumNode('foo', null, array('foo', 'bar'));
53         $node->finalize('foobar');
54     }
55 }