Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / psy / psysh / test / Formatter / SignatureFormatterTest.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\Formatter;
13
14 use Psy\Formatter\SignatureFormatter;
15 use Psy\Reflection\ReflectionClassConstant;
16 use Psy\Reflection\ReflectionConstant_;
17
18 class SignatureFormatterTest extends \PHPUnit\Framework\TestCase
19 {
20     const FOO = 'foo value';
21     private static $bar = 'bar value';
22
23     private function someFakeMethod(array $one, $two = 'TWO', \Reflector $three = null)
24     {
25     }
26
27     /**
28      * @dataProvider signatureReflectors
29      */
30     public function testFormat($reflector, $expected)
31     {
32         $this->assertSame($expected, \strip_tags(SignatureFormatter::format($reflector)));
33     }
34
35     public function signatureReflectors()
36     {
37         return [
38             [
39                 new \ReflectionFunction('implode'),
40                 \defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
41             ],
42             [
43                 ReflectionClassConstant::create($this, 'FOO'),
44                 'const FOO = "foo value"',
45             ],
46             [
47                 new \ReflectionMethod($this, 'someFakeMethod'),
48                 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
49             ],
50             [
51                 new \ReflectionProperty($this, 'bar'),
52                 'private static $bar',
53             ],
54             [
55                 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
56                 'abstract class Psy\CodeCleaner\CodeCleanerPass '
57                 . 'extends PhpParser\NodeVisitorAbstract '
58                 . 'implements PhpParser\NodeVisitor',
59             ],
60             [
61                 new \ReflectionFunction('array_chunk'),
62                 'function array_chunk($arg, $size, $preserve_keys = unknown)',
63             ],
64             [
65                 new \ReflectionClass('Psy\Test\Formatter\Fixtures\BoringTrait'),
66                 'trait Psy\Test\Formatter\Fixtures\BoringTrait',
67             ],
68             [
69                 new \ReflectionMethod('Psy\Test\Formatter\Fixtures\BoringTrait', 'boringMethod'),
70                 'public function boringMethod($one = 1)',
71             ],
72             [
73                 new ReflectionConstant_('E_ERROR'),
74                 'define("E_ERROR", 1)',
75             ],
76             [
77                 new ReflectionConstant_('PHP_VERSION'),
78                 'define("PHP_VERSION", "' . PHP_VERSION . '")',
79             ],
80             [
81                 new ReflectionConstant_('__LINE__'),
82                 'define("__LINE__", null)', // @todo show this as `unknown` in red or something?
83             ],
84         ];
85     }
86
87     /**
88      * @expectedException \InvalidArgumentException
89      */
90     public function testSignatureFormatterThrowsUnknownReflectorExpeption()
91     {
92         $refl = $this->getMockBuilder('Reflector')->getMock();
93         SignatureFormatter::format($refl);
94     }
95 }