Chris@13: assertFalse($refl->getDocComment()); Chris@16: $this->assertEquals('Psy\\Test\\Reflection\\SOME_CONSTANT', $refl->getName()); Chris@16: $this->assertEquals('Psy\\Test\\Reflection', $refl->getNamespaceName()); Chris@16: $this->assertEquals('yep', $refl->getValue()); Chris@16: $this->assertTrue($refl->inNamespace()); Chris@16: $this->assertEquals('Psy\\Test\\Reflection\\SOME_CONSTANT', (string) $refl); Chris@13: $this->assertNull($refl->getFileName()); Chris@16: } Chris@16: Chris@16: public function testBuiltInConstant() Chris@16: { Chris@16: $refl = new ReflectionConstant_('PHP_VERSION'); Chris@16: Chris@16: $this->assertEquals('PHP_VERSION', $refl->getName()); Chris@16: $this->assertEquals('PHP_VERSION', (string) $refl); Chris@16: $this->assertEquals(PHP_VERSION, $refl->getValue()); Chris@16: $this->assertFalse($refl->inNamespace()); Chris@16: $this->assertSame('', $refl->getNamespaceName()); Chris@16: } Chris@16: Chris@16: /** Chris@16: * @dataProvider magicConstants Chris@16: */ Chris@16: public function testIsMagicConstant($name, $is) Chris@16: { Chris@16: $this->assertEquals($is, ReflectionConstant_::isMagicConstant($name)); Chris@16: } Chris@16: Chris@16: public function magicConstants() Chris@16: { Chris@16: return [ Chris@16: ['__LINE__', true], Chris@16: ['__FILE__', true], Chris@16: ['__DIR__', true], Chris@16: ['__FUNCTION__', true], Chris@16: ['__CLASS__', true], Chris@16: ['__TRAIT__', true], Chris@16: ['__METHOD__', true], Chris@16: ['__NAMESPACE__', true], Chris@16: ['__COMPILER_HALT_OFFSET__', true], Chris@16: ['PHP_VERSION', false], Chris@16: ['PHP_EOL', false], Chris@16: ['Psy\\Test\\Reflection\\SOME_CONSTANT', false], Chris@16: ['What if it isn\'t even a valid constant name?', false], Chris@16: ]; Chris@13: } Chris@13: Chris@13: /** Chris@13: * @expectedException \InvalidArgumentException Chris@13: */ Chris@13: public function testUnknownConstantThrowsException() Chris@13: { Chris@16: new ReflectionConstant_('UNKNOWN_CONSTANT'); Chris@16: } Chris@16: Chris@16: public function testExport() Chris@16: { Chris@16: $ret = ReflectionConstant_::export('Psy\\Test\\Reflection\\SOME_CONSTANT', true); Chris@16: $this->assertEquals($ret, 'Constant [ string Psy\\Test\\Reflection\\SOME_CONSTANT ] { yep }'); Chris@16: } Chris@16: Chris@16: public function testExportOutput() Chris@16: { Chris@16: $this->expectOutputString("Constant [ string Psy\\Test\\Reflection\\SOME_CONSTANT ] { yep }\n"); Chris@16: ReflectionConstant_::export('Psy\\Test\\Reflection\\SOME_CONSTANT', false); Chris@16: } Chris@16: Chris@16: public function testGetFileName() Chris@16: { Chris@16: $refl = new ReflectionConstant_('Psy\\Test\\Reflection\\SOME_CONSTANT'); Chris@16: $this->assertNull($refl->getFileName()); Chris@13: } Chris@13: Chris@13: /** Chris@13: * @expectedException \RuntimeException Chris@13: * @dataProvider notYetImplemented Chris@13: */ Chris@13: public function testNotYetImplemented($method) Chris@13: { Chris@16: $refl = new ReflectionConstant_('Psy\\Test\\Reflection\\SOME_CONSTANT'); Chris@13: $refl->$method(); Chris@13: } Chris@13: Chris@13: public function notYetImplemented() Chris@13: { Chris@13: return [ Chris@13: ['getStartLine'], Chris@13: ['getEndLine'], Chris@13: ]; Chris@13: } Chris@13: }