73511fb1f57de9bb4bb1a46deae82499b6374d76
[yaffs-website] / vendor / psy / psysh / test / Psy / Test / Formatter / SignatureFormatterTest.php
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\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->assertEquals($expected, strip_tags(SignatureFormatter::format($reflector)));
32     }
33
34     public function signatureReflectors()
35     {
36         return array(
37             array(
38                 new \ReflectionFunction('implode'),
39                 defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
40             ),
41             array(
42                 new ReflectionConstant($this, 'FOO'),
43                 'const FOO = "foo value"',
44             ),
45             array(
46                 new \ReflectionMethod($this, 'someFakeMethod'),
47                 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
48             ),
49             array(
50                 new \ReflectionProperty($this, 'bar'),
51                 'private static $bar',
52             ),
53             array(
54                 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
55                 'abstract class Psy\CodeCleaner\CodeCleanerPass '
56                 . 'extends PhpParser\NodeVisitorAbstract '
57                 . 'implements PhpParser\NodeVisitor',
58             ),
59         );
60     }
61
62     /**
63      * @expectedException \InvalidArgumentException
64      */
65     public function testSignatureFormatterThrowsUnknownReflectorExpeption()
66     {
67         $refl = $this->getMockBuilder('Reflector')->getMock();
68         SignatureFormatter::format($refl);
69     }
70 }