Sin descripción

ArgumentMetadataTest.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\HttpKernel\Tests\ControllerMetadata;
  11. use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
  12. class ArgumentMetadataTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testWithBcLayerWithDefault()
  15. {
  16. $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value');
  17. $this->assertFalse($argument->isNullable());
  18. }
  19. public function testDefaultValueAvailable()
  20. {
  21. $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value', true);
  22. $this->assertTrue($argument->isNullable());
  23. $this->assertTrue($argument->hasDefaultValue());
  24. $this->assertSame('default value', $argument->getDefaultValue());
  25. }
  26. /**
  27. * @expectedException \LogicException
  28. */
  29. public function testDefaultValueUnavailable()
  30. {
  31. $argument = new ArgumentMetadata('foo', 'string', false, false, null, false);
  32. $this->assertFalse($argument->isNullable());
  33. $this->assertFalse($argument->hasDefaultValue());
  34. $argument->getDefaultValue();
  35. }
  36. }