Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / psy / psysh / test / Util / MirrorTest.php
1 <?php
2
3 /*
4  * This file is part of Psy Shell.
5  *
6  * (c) 2012-2018 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\Util\Mirror;
15
16 class MirrorTest extends \PHPUnit\Framework\TestCase
17 {
18     const FOO           = 1;
19     private $bar        = 2;
20     private static $baz = 3;
21
22     public function aPublicMethod()
23     {
24         // nada
25     }
26
27     public function testMirror()
28     {
29         $refl = Mirror::get('sort');
30         $this->assertInstanceOf('ReflectionFunction', $refl);
31
32         $refl = Mirror::get('Psy\Test\Util\MirrorTest');
33         $this->assertInstanceOf('ReflectionClass', $refl);
34
35         $refl = Mirror::get($this);
36         $this->assertInstanceOf('ReflectionObject', $refl);
37
38         $refl = Mirror::get($this, 'FOO');
39         $this->assertInstanceOf('Psy\Reflection\ReflectionConstant', $refl);
40
41         $refl = Mirror::get($this, 'bar');
42         $this->assertInstanceOf('ReflectionProperty', $refl);
43
44         $refl = Mirror::get($this, 'baz');
45         $this->assertInstanceOf('ReflectionProperty', $refl);
46
47         $refl = Mirror::get($this, 'aPublicMethod');
48         $this->assertInstanceOf('ReflectionMethod', $refl);
49
50         $refl = Mirror::get($this, 'baz', Mirror::STATIC_PROPERTY);
51         $this->assertInstanceOf('ReflectionProperty', $refl);
52     }
53
54     /**
55      * @expectedException \RuntimeException
56      */
57     public function testMirrorThrowsExceptions()
58     {
59         Mirror::get($this, 'notAMethod');
60     }
61
62     /**
63      * @expectedException \InvalidArgumentException
64      * @dataProvider invalidArguments
65      */
66     public function testMirrorThrowsInvalidArgumentExceptions($value)
67     {
68         Mirror::get($value);
69     }
70
71     public function invalidArguments()
72     {
73         return [
74             ['not_a_function_or_class'],
75             [[]],
76             [1],
77         ];
78     }
79 }