Updated from some -dev modules to alpha, beta or full releases
[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\ReflectionConstant;
16
17 class SignatureFormatterTest extends \PHPUnit\Framework\TestCase
18 {
19     const FOO = 'foo value';
20     private static $bar = 'bar value';
21
22     private function someFakeMethod(array $one, $two = 'TWO', \Reflector $three = null)
23     {
24     }
25
26     /**
27      * @dataProvider signatureReflectors
28      */
29     public function testFormat($reflector, $expected)
30     {
31         $this->assertSame($expected, strip_tags(SignatureFormatter::format($reflector)));
32     }
33
34     public function signatureReflectors()
35     {
36         return [
37             [
38                 new \ReflectionFunction('implode'),
39                 defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
40             ],
41             [
42                 new ReflectionConstant($this, 'FOO'),
43                 'const FOO = "foo value"',
44             ],
45             [
46                 new \ReflectionMethod($this, 'someFakeMethod'),
47                 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
48             ],
49             [
50                 new \ReflectionProperty($this, 'bar'),
51                 'private static $bar',
52             ],
53             [
54                 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
55                 'abstract class Psy\CodeCleaner\CodeCleanerPass '
56                 . 'extends PhpParser\NodeVisitorAbstract '
57                 . 'implements PhpParser\NodeVisitor',
58             ],
59             [
60                 new \ReflectionFunction('array_chunk'),
61                 'function array_chunk($arg, $size, $preserve_keys = unknown)',
62             ],
63             [
64                 new \ReflectionClass('Psy\Test\Formatter\Fixtures\BoringTrait'),
65                 'trait Psy\Test\Formatter\Fixtures\BoringTrait',
66             ],
67             [
68                 new \ReflectionMethod('Psy\Test\Formatter\Fixtures\BoringTrait', 'boringMethod'),
69                 'public function boringMethod($one = 1)',
70             ],
71         ];
72     }
73
74     /**
75      * @expectedException \InvalidArgumentException
76      */
77     public function testSignatureFormatterThrowsUnknownReflectorExpeption()
78     {
79         $refl = $this->getMockBuilder('Reflector')->getMock();
80         SignatureFormatter::format($refl);
81     }
82 }