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\Util;
16 class MirrorTest extends \PHPUnit\Framework\TestCase
20 private static $baz = 3;
22 public function aPublicMethod()
27 public function testMirror()
29 $refl = Mirror::get('sort');
30 $this->assertInstanceOf('ReflectionFunction', $refl);
32 $refl = Mirror::get('Psy\Test\Util\MirrorTest');
33 $this->assertInstanceOf('ReflectionClass', $refl);
35 $refl = Mirror::get($this);
36 $this->assertInstanceOf('ReflectionObject', $refl);
38 $refl = Mirror::get($this, 'FOO');
39 if (\version_compare(PHP_VERSION, '7.1.0', '>=')) {
40 $this->assertInstanceOf('ReflectionClassConstant', $refl);
42 $this->assertInstanceOf('Psy\Reflection\ReflectionClassConstant', $refl);
45 $refl = Mirror::get('PHP_VERSION');
46 $this->assertInstanceOf('Psy\Reflection\ReflectionConstant_', $refl);
48 $refl = Mirror::get($this, 'bar');
49 $this->assertInstanceOf('ReflectionProperty', $refl);
51 $refl = Mirror::get($this, 'baz');
52 $this->assertInstanceOf('ReflectionProperty', $refl);
54 $refl = Mirror::get($this, 'aPublicMethod');
55 $this->assertInstanceOf('ReflectionMethod', $refl);
57 $refl = Mirror::get($this, 'baz', Mirror::STATIC_PROPERTY);
58 $this->assertInstanceOf('ReflectionProperty', $refl);
62 * @expectedException \RuntimeException
64 public function testMirrorThrowsExceptions()
66 Mirror::get($this, 'notAMethod');
70 * @expectedException \InvalidArgumentException
71 * @dataProvider invalidArguments
73 public function testMirrorThrowsInvalidArgumentExceptions($value)
78 public function invalidArguments()
81 ['not_a_function_or_class'],