ReflectionLanguageConstructParameterTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2018 Justin Hileman
  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 Psy\Test\Reflection;
  11. use Psy\Reflection\ReflectionLanguageConstruct;
  12. use Psy\Reflection\ReflectionLanguageConstructParameter;
  13. class ReflectionLanguageConstructParameterTest extends \PHPUnit\Framework\TestCase
  14. {
  15. public function testOptions()
  16. {
  17. $keyword = new ReflectionLanguageConstruct('die');
  18. $refl = new ReflectionLanguageConstructParameter($keyword, 'one', [
  19. 'isArray' => false,
  20. 'defaultValue' => null,
  21. 'isOptional' => false,
  22. 'isPassedByReference' => false,
  23. ]);
  24. $this->assertNull($refl->getClass());
  25. $this->assertEquals('one', $refl->getName());
  26. $this->assertFalse($refl->isArray());
  27. $this->assertTrue($refl->isDefaultValueAvailable());
  28. $this->assertNull($refl->getDefaultValue());
  29. $this->assertFalse($refl->isOptional());
  30. $this->assertFalse($refl->isPassedByReference());
  31. $reflTwo = new ReflectionLanguageConstructParameter($keyword, 'two', [
  32. 'isArray' => true,
  33. 'isOptional' => true,
  34. 'isPassedByReference' => true,
  35. ]);
  36. $this->assertNull($refl->getClass());
  37. $this->assertEquals('two', $reflTwo->getName());
  38. $this->assertTrue($reflTwo->isArray());
  39. $this->assertFalse($reflTwo->isDefaultValueAvailable());
  40. $this->assertNull($reflTwo->getDefaultValue());
  41. $this->assertTrue($reflTwo->isOptional());
  42. $this->assertTrue($reflTwo->isPassedByReference());
  43. $refl = new ReflectionLanguageConstructParameter($keyword, 'three', [
  44. 'defaultValue' => 3,
  45. ]);
  46. $this->assertNull($refl->getClass());
  47. $this->assertEquals('three', $refl->getName());
  48. $this->assertFalse($refl->isArray());
  49. $this->assertTrue($refl->isDefaultValueAvailable());
  50. $this->assertEquals(3, $refl->getDefaultValue());
  51. $this->assertFalse($refl->isOptional());
  52. $this->assertFalse($refl->isPassedByReference());
  53. }
  54. }