4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Tests\Definition;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\EnumNode;
17 class EnumNodeTest extends TestCase
19 public function testFinalizeValue()
21 $node = new EnumNode('foo', null, array('foo', 'bar'));
22 $this->assertSame('foo', $node->finalize('foo'));
26 * @expectedException \InvalidArgumentException
27 * @expectedExceptionMessage $values must contain at least one element.
29 public function testConstructionWithNoValues()
31 new EnumNode('foo', null, array());
34 public function testConstructionWithOneValue()
36 $node = new EnumNode('foo', null, array('foo'));
37 $this->assertSame('foo', $node->finalize('foo'));
40 public function testConstructionWithOneDistinctValue()
42 $node = new EnumNode('foo', null, array('foo', 'foo'));
43 $this->assertSame('foo', $node->finalize('foo'));
47 * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
48 * @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"
50 public function testFinalizeWithInvalidValue()
52 $node = new EnumNode('foo', null, array('foo', 'bar'));
53 $node->finalize('foobar');