EnumNodeTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Config\Tests\Definition;
  11. use Symfony\Component\Config\Definition\EnumNode;
  12. class EnumNodeTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testFinalizeValue()
  15. {
  16. $node = new EnumNode('foo', null, array('foo', 'bar'));
  17. $this->assertSame('foo', $node->finalize('foo'));
  18. }
  19. /**
  20. * @expectedException \InvalidArgumentException
  21. */
  22. public function testConstructionWithOneValue()
  23. {
  24. new EnumNode('foo', null, array('foo', 'foo'));
  25. }
  26. /**
  27. * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
  28. * @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"
  29. */
  30. public function testFinalizeWithInvalidValue()
  31. {
  32. $node = new EnumNode('foo', null, array('foo', 'bar'));
  33. $node->finalize('foobar');
  34. }
  35. }