Yaffs site version 1.1
[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 \ReflectionClass($this),
39                 "class Psy\Test\Formatter\SignatureFormatterTest "
40                 . 'extends PHPUnit_Framework_TestCase implements '
41                 . 'Countable, PHPUnit_Framework_SelfDescribing, '
42                 . 'PHPUnit_Framework_Test',
43             ),
44             array(
45                 new \ReflectionFunction('implode'),
46                 defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
47             ),
48             array(
49                 new ReflectionConstant($this, 'FOO'),
50                 'const FOO = "foo value"',
51             ),
52             array(
53                 new \ReflectionMethod($this, 'someFakeMethod'),
54                 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
55             ),
56             array(
57                 new \ReflectionProperty($this, 'bar'),
58                 'private static $bar',
59             ),
60             array(
61                 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
62                 'abstract class Psy\CodeCleaner\CodeCleanerPass '
63                 . 'extends PhpParser\NodeVisitorAbstract '
64                 . 'implements PhpParser\NodeVisitor',
65             ),
66         );
67     }
68
69     /**
70      * @expectedException \InvalidArgumentException
71      */
72     public function testSignatureFormatterThrowsUnknownReflectorExpeption()
73     {
74         $refl = $this->getMockBuilder('Reflector')->getMock();
75         SignatureFormatter::format($refl);
76     }
77 }