4 * This file is part of Psy Shell.
6 * (c) 2012-2018 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\Formatter;
14 use Psy\Formatter\SignatureFormatter;
15 use Psy\Reflection\ReflectionClassConstant;
16 use Psy\Reflection\ReflectionConstant_;
18 class SignatureFormatterTest extends \PHPUnit\Framework\TestCase
20 const FOO = 'foo value';
21 private static $bar = 'bar value';
23 private function someFakeMethod(array $one, $two = 'TWO', \Reflector $three = null)
28 * @dataProvider signatureReflectors
30 public function testFormat($reflector, $expected)
32 $this->assertSame($expected, \strip_tags(SignatureFormatter::format($reflector)));
35 public function signatureReflectors()
39 new \ReflectionFunction('implode'),
40 \defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
43 ReflectionClassConstant::create($this, 'FOO'),
44 'const FOO = "foo value"',
47 new \ReflectionMethod($this, 'someFakeMethod'),
48 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
51 new \ReflectionProperty($this, 'bar'),
52 'private static $bar',
55 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
56 'abstract class Psy\CodeCleaner\CodeCleanerPass '
57 . 'extends PhpParser\NodeVisitorAbstract '
58 . 'implements PhpParser\NodeVisitor',
61 new \ReflectionFunction('array_chunk'),
62 'function array_chunk($arg, $size, $preserve_keys = unknown)',
65 new \ReflectionClass('Psy\Test\Formatter\Fixtures\BoringTrait'),
66 'trait Psy\Test\Formatter\Fixtures\BoringTrait',
69 new \ReflectionMethod('Psy\Test\Formatter\Fixtures\BoringTrait', 'boringMethod'),
70 'public function boringMethod($one = 1)',
73 new ReflectionConstant_('E_ERROR'),
74 'define("E_ERROR", 1)',
77 new ReflectionConstant_('PHP_VERSION'),
78 'define("PHP_VERSION", "' . PHP_VERSION . '")',
81 new ReflectionConstant_('__LINE__'),
82 'define("__LINE__", null)', // @todo show this as `unknown` in red or something?
88 * @expectedException \InvalidArgumentException
90 public function testSignatureFormatterThrowsUnknownReflectorExpeption()
92 $refl = $this->getMockBuilder('Reflector')->getMock();
93 SignatureFormatter::format($refl);