ReflectionConstantTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2017 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\ReflectionConstant;
  12. class ReflectionConstantTest extends \PHPUnit_Framework_TestCase
  13. {
  14. const CONSTANT_ONE = 'one';
  15. public function testConstruction()
  16. {
  17. $refl = new ReflectionConstant($this, 'CONSTANT_ONE');
  18. $class = $refl->getDeclaringClass();
  19. $this->assertTrue($class instanceof \ReflectionClass);
  20. $this->assertEquals('Psy\Test\Reflection\ReflectionConstantTest', $class->getName());
  21. $this->assertEquals('CONSTANT_ONE', $refl->getName());
  22. $this->assertEquals('CONSTANT_ONE', (string) $refl);
  23. $this->assertEquals('one', $refl->getValue());
  24. $this->assertEquals(null, $refl->getFileName());
  25. $this->assertFalse($refl->getDocComment());
  26. }
  27. /**
  28. * @expectedException \InvalidArgumentException
  29. */
  30. public function testUnknownConstantThrowsException()
  31. {
  32. new ReflectionConstant($this, 'UNKNOWN_CONSTANT');
  33. }
  34. /**
  35. * @expectedException \RuntimeException
  36. * @dataProvider notYetImplemented
  37. */
  38. public function testNotYetImplemented($method)
  39. {
  40. $refl = new ReflectionConstant($this, 'CONSTANT_ONE');
  41. $refl->$method();
  42. }
  43. public function notYetImplemented()
  44. {
  45. return array(
  46. array('getStartLine'),
  47. array('getEndLine'),
  48. array('export'),
  49. );
  50. }
  51. }