annotate vendor/psy/psysh/test/Reflection/ReflectionClassConstantTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents c2387f117808
children
rev   line source
Chris@16 1 <?php
Chris@16 2
Chris@16 3 /*
Chris@16 4 * This file is part of Psy Shell.
Chris@16 5 *
Chris@16 6 * (c) 2012-2018 Justin Hileman
Chris@16 7 *
Chris@16 8 * For the full copyright and license information, please view the LICENSE
Chris@16 9 * file that was distributed with this source code.
Chris@16 10 */
Chris@16 11
Chris@16 12 namespace Psy\Test\Reflection;
Chris@16 13
Chris@16 14 use Psy\Reflection\ReflectionClassConstant;
Chris@16 15
Chris@16 16 class ReflectionClassConstantTest extends \PHPUnit\Framework\TestCase
Chris@16 17 {
Chris@16 18 const CONSTANT_ONE = 'one';
Chris@16 19
Chris@16 20 public function testConstruction()
Chris@16 21 {
Chris@16 22 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
Chris@16 23 $class = $refl->getDeclaringClass();
Chris@16 24
Chris@16 25 $this->assertInstanceOf('ReflectionClass', $class);
Chris@16 26 $this->assertSame('Psy\Test\Reflection\ReflectionClassConstantTest', $class->getName());
Chris@16 27 $this->assertSame('CONSTANT_ONE', $refl->getName());
Chris@16 28 $this->assertSame('CONSTANT_ONE', (string) $refl);
Chris@16 29 $this->assertSame('one', $refl->getValue());
Chris@16 30 $this->assertNull($refl->getFileName());
Chris@16 31 $this->assertFalse($refl->getDocComment());
Chris@16 32 }
Chris@16 33
Chris@16 34 /**
Chris@16 35 * @expectedException \InvalidArgumentException
Chris@16 36 */
Chris@16 37 public function testUnknownConstantThrowsException()
Chris@16 38 {
Chris@16 39 new ReflectionClassConstant($this, 'UNKNOWN_CONSTANT');
Chris@16 40 }
Chris@16 41
Chris@16 42 public function testExport()
Chris@16 43 {
Chris@16 44 $ret = ReflectionClassConstant::export($this, 'CONSTANT_ONE', true);
Chris@16 45 $this->assertEquals($ret, 'Constant [ public string CONSTANT_ONE ] { one }');
Chris@16 46 }
Chris@16 47
Chris@16 48 public function testExportOutput()
Chris@16 49 {
Chris@16 50 $this->expectOutputString("Constant [ public string CONSTANT_ONE ] { one }\n");
Chris@16 51 ReflectionClassConstant::export($this, 'CONSTANT_ONE', false);
Chris@16 52 }
Chris@16 53
Chris@16 54 public function testModifiers()
Chris@16 55 {
Chris@16 56 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
Chris@16 57
Chris@16 58 $this->assertEquals(\ReflectionMethod::IS_PUBLIC, $refl->getModifiers());
Chris@16 59 $this->assertFalse($refl->isPrivate());
Chris@16 60 $this->assertFalse($refl->isProtected());
Chris@16 61 $this->assertTrue($refl->isPublic());
Chris@16 62 }
Chris@16 63
Chris@16 64 /**
Chris@16 65 * @expectedException \RuntimeException
Chris@16 66 * @dataProvider notYetImplemented
Chris@16 67 */
Chris@16 68 public function testNotYetImplemented($method)
Chris@16 69 {
Chris@16 70 $refl = new ReflectionClassConstant($this, 'CONSTANT_ONE');
Chris@16 71 $refl->$method();
Chris@16 72 }
Chris@16 73
Chris@16 74 public function notYetImplemented()
Chris@16 75 {
Chris@16 76 return [
Chris@16 77 ['getStartLine'],
Chris@16 78 ['getEndLine'],
Chris@16 79 ];
Chris@16 80 }
Chris@16 81 }