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\Builder;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
17 class EnumNodeDefinitionTest extends TestCase
19 public function testWithOneValue()
21 $def = new EnumNodeDefinition('foo');
22 $def->values(array('foo'));
24 $node = $def->getNode();
25 $this->assertEquals(array('foo'), $node->getValues());
28 public function testWithOneDistinctValue()
30 $def = new EnumNodeDefinition('foo');
31 $def->values(array('foo', 'foo'));
33 $node = $def->getNode();
34 $this->assertEquals(array('foo'), $node->getValues());
38 * @expectedException \RuntimeException
39 * @expectedExceptionMessage You must call ->values() on enum nodes.
41 public function testNoValuesPassed()
43 $def = new EnumNodeDefinition('foo');
48 * @expectedException \InvalidArgumentException
49 * @expectedExceptionMessage ->values() must be called with at least one value.
51 public function testWithNoValues()
53 $def = new EnumNodeDefinition('foo');
54 $def->values(array());
57 public function testGetNode()
59 $def = new EnumNodeDefinition('foo');
60 $def->values(array('foo', 'bar'));
62 $node = $def->getNode();
63 $this->assertEquals(array('foo', 'bar'), $node->getValues());