ArgumentMetadataTest.php 1.3 KB

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