4 * This file is part of Psy Shell.
6 * (c) 2012-2018 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\Reflection;
14 use Psy\Reflection\ReflectionClassConstant;
16 class ReflectionClassConstantTest extends \PHPUnit\Framework\TestCase
18 const CONSTANT_ONE = 'one';
20 public function testConstruction()
22 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
23 $class = $refl->getDeclaringClass();
25 $this->assertInstanceOf('ReflectionClass', $class);
26 $this->assertSame('Psy\Test\Reflection\ReflectionClassConstantTest', $class->getName());
27 $this->assertSame('CONSTANT_ONE', $refl->getName());
28 $this->assertSame('CONSTANT_ONE', (string) $refl);
29 $this->assertSame('one', $refl->getValue());
30 $this->assertNull($refl->getFileName());
31 $this->assertFalse($refl->getDocComment());
35 * @expectedException \InvalidArgumentException
37 public function testUnknownConstantThrowsException()
39 new ReflectionClassConstant($this, 'UNKNOWN_CONSTANT');
42 public function testExport()
44 $ret = ReflectionClassConstant::export($this, 'CONSTANT_ONE', true);
45 $this->assertEquals($ret, 'Constant [ public string CONSTANT_ONE ] { one }');
48 public function testExportOutput()
50 $this->expectOutputString("Constant [ public string CONSTANT_ONE ] { one }\n");
51 ReflectionClassConstant::export($this, 'CONSTANT_ONE', false);
54 public function testModifiers()
56 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
58 $this->assertEquals(\ReflectionMethod::IS_PUBLIC, $refl->getModifiers());
59 $this->assertFalse($refl->isPrivate());
60 $this->assertFalse($refl->isProtected());
61 $this->assertTrue($refl->isPublic());
65 * @expectedException \RuntimeException
66 * @dataProvider notYetImplemented
68 public function testNotYetImplemented($method)
70 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
74 public function notYetImplemented()