Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/Psy/Test/Util/MirrorTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2017 Justin Hileman | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Psy\Test\Util; | |
13 | |
14 use Psy\Reflection\ReflectionConstant; | |
15 use Psy\Util\Mirror; | |
16 | |
17 class MirrorTest extends \PHPUnit\Framework\TestCase | |
18 { | |
19 const FOO = 1; | |
20 private $bar = 2; | |
21 private static $baz = 3; | |
22 | |
23 public function aPublicMethod() | |
24 { | |
25 // nada | |
26 } | |
27 | |
28 public function testMirror() | |
29 { | |
30 $refl = Mirror::get('sort'); | |
31 $this->assertTrue($refl instanceof \ReflectionFunction); | |
32 | |
33 $refl = Mirror::get('Psy\Test\Util\MirrorTest'); | |
34 $this->assertTrue($refl instanceof \ReflectionClass); | |
35 | |
36 $refl = Mirror::get($this); | |
37 $this->assertTrue($refl instanceof \ReflectionObject); | |
38 | |
39 $refl = Mirror::get($this, 'FOO'); | |
40 $this->assertTrue($refl instanceof ReflectionConstant); | |
41 | |
42 $refl = Mirror::get($this, 'bar'); | |
43 $this->assertTrue($refl instanceof \ReflectionProperty); | |
44 | |
45 $refl = Mirror::get($this, 'baz'); | |
46 $this->assertTrue($refl instanceof \ReflectionProperty); | |
47 | |
48 $refl = Mirror::get($this, 'aPublicMethod'); | |
49 $this->assertTrue($refl instanceof \ReflectionMethod); | |
50 | |
51 $refl = Mirror::get($this, 'baz', Mirror::STATIC_PROPERTY); | |
52 $this->assertTrue($refl instanceof \ReflectionProperty); | |
53 } | |
54 | |
55 /** | |
56 * @expectedException \RuntimeException | |
57 */ | |
58 public function testMirrorThrowsExceptions() | |
59 { | |
60 Mirror::get($this, 'notAMethod'); | |
61 } | |
62 | |
63 /** | |
64 * @expectedException \InvalidArgumentException | |
65 * @dataProvider invalidArguments | |
66 */ | |
67 public function testMirrorThrowsInvalidArgumentExceptions($value) | |
68 { | |
69 Mirror::get($value); | |
70 } | |
71 | |
72 public function invalidArguments() | |
73 { | |
74 return array( | |
75 array('not_a_function_or_class'), | |
76 array(array()), | |
77 array(1), | |
78 ); | |
79 } | |
80 } |