Updated Drupal to 8.6. This goes with the following updates because it's possible...
[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         if (\version_compare(PHP_VERSION, '7.1.0', '>=')) {
40             $this->assertInstanceOf('ReflectionClassConstant', $refl);
41         } else {
42             $this->assertInstanceOf('Psy\Reflection\ReflectionClassConstant', $refl);
43         }
44
45         $refl = Mirror::get('PHP_VERSION');
46         $this->assertInstanceOf('Psy\Reflection\ReflectionConstant_', $refl);
47
48         $refl = Mirror::get($this, 'bar');
49         $this->assertInstanceOf('ReflectionProperty', $refl);
50
51         $refl = Mirror::get($this, 'baz');
52         $this->assertInstanceOf('ReflectionProperty', $refl);
53
54         $refl = Mirror::get($this, 'aPublicMethod');
55         $this->assertInstanceOf('ReflectionMethod', $refl);
56
57         $refl = Mirror::get($this, 'baz', Mirror::STATIC_PROPERTY);
58         $this->assertInstanceOf('ReflectionProperty', $refl);
59     }
60
61     /**
62      * @expectedException \RuntimeException
63      */
64     public function testMirrorThrowsExceptions()
65     {
66         Mirror::get($this, 'notAMethod');
67     }
68
69     /**
70      * @expectedException \InvalidArgumentException
71      * @dataProvider invalidArguments
72      */
73     public function testMirrorThrowsInvalidArgumentExceptions($value)
74     {
75         Mirror::get($value);
76     }
77
78     public function invalidArguments()
79     {
80         return [
81             ['not_a_function_or_class'],
82             [[]],
83             [1],
84         ];
85     }
86 }