+ $this->assertEquals('Psy\\Test\\Reflection\\SOME_CONSTANT', $refl->getName());
+ $this->assertEquals('Psy\\Test\\Reflection', $refl->getNamespaceName());
+ $this->assertEquals('yep', $refl->getValue());
+ $this->assertTrue($refl->inNamespace());
+ $this->assertEquals('Psy\\Test\\Reflection\\SOME_CONSTANT', (string) $refl);
+ $this->assertNull($refl->getFileName());
+ }
+
+ public function testBuiltInConstant()
+ {
+ $refl = new ReflectionConstant_('PHP_VERSION');
+
+ $this->assertEquals('PHP_VERSION', $refl->getName());
+ $this->assertEquals('PHP_VERSION', (string) $refl);
+ $this->assertEquals(PHP_VERSION, $refl->getValue());
+ $this->assertFalse($refl->inNamespace());
+ $this->assertSame('', $refl->getNamespaceName());
+ }
+
+ /**
+ * @dataProvider magicConstants
+ */
+ public function testIsMagicConstant($name, $is)
+ {
+ $this->assertEquals($is, ReflectionConstant_::isMagicConstant($name));
+ }
+
+ public function magicConstants()
+ {
+ return [
+ ['__LINE__', true],
+ ['__FILE__', true],
+ ['__DIR__', true],
+ ['__FUNCTION__', true],
+ ['__CLASS__', true],
+ ['__TRAIT__', true],
+ ['__METHOD__', true],
+ ['__NAMESPACE__', true],
+ ['__COMPILER_HALT_OFFSET__', true],
+ ['PHP_VERSION', false],
+ ['PHP_EOL', false],
+ ['Psy\\Test\\Reflection\\SOME_CONSTANT', false],
+ ['What if it isn\'t even a valid constant name?', false],
+ ];