Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of Psy Shell.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) 2012-2017 Justin Hileman
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Psy\Test\Reflection;
|
Chris@0
|
13
|
Chris@0
|
14 use Psy\Reflection\ReflectionConstant;
|
Chris@0
|
15
|
Chris@0
|
16 class ReflectionConstantTest extends \PHPUnit\Framework\TestCase
|
Chris@0
|
17 {
|
Chris@0
|
18 const CONSTANT_ONE = 'one';
|
Chris@0
|
19
|
Chris@0
|
20 public function testConstruction()
|
Chris@0
|
21 {
|
Chris@0
|
22 $refl = new ReflectionConstant($this, 'CONSTANT_ONE');
|
Chris@0
|
23 $class = $refl->getDeclaringClass();
|
Chris@0
|
24
|
Chris@0
|
25 $this->assertTrue($class instanceof \ReflectionClass);
|
Chris@0
|
26 $this->assertEquals('Psy\Test\Reflection\ReflectionConstantTest', $class->getName());
|
Chris@0
|
27 $this->assertEquals('CONSTANT_ONE', $refl->getName());
|
Chris@0
|
28 $this->assertEquals('CONSTANT_ONE', (string) $refl);
|
Chris@0
|
29 $this->assertEquals('one', $refl->getValue());
|
Chris@0
|
30 $this->assertEquals(null, $refl->getFileName());
|
Chris@0
|
31 $this->assertFalse($refl->getDocComment());
|
Chris@0
|
32 }
|
Chris@0
|
33
|
Chris@0
|
34 /**
|
Chris@0
|
35 * @expectedException \InvalidArgumentException
|
Chris@0
|
36 */
|
Chris@0
|
37 public function testUnknownConstantThrowsException()
|
Chris@0
|
38 {
|
Chris@0
|
39 new ReflectionConstant($this, 'UNKNOWN_CONSTANT');
|
Chris@0
|
40 }
|
Chris@0
|
41
|
Chris@0
|
42 /**
|
Chris@0
|
43 * @expectedException \RuntimeException
|
Chris@0
|
44 * @dataProvider notYetImplemented
|
Chris@0
|
45 */
|
Chris@0
|
46 public function testNotYetImplemented($method)
|
Chris@0
|
47 {
|
Chris@0
|
48 $refl = new ReflectionConstant($this, 'CONSTANT_ONE');
|
Chris@0
|
49 $refl->$method();
|
Chris@0
|
50 }
|
Chris@0
|
51
|
Chris@0
|
52 public function notYetImplemented()
|
Chris@0
|
53 {
|
Chris@0
|
54 return array(
|
Chris@0
|
55 array('getStartLine'),
|
Chris@0
|
56 array('getEndLine'),
|
Chris@0
|
57 array('export'),
|
Chris@0
|
58 );
|
Chris@0
|
59 }
|
Chris@0
|
60 }
|