annotate vendor/psy/psysh/test/Formatter/SignatureFormatterTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@13 1 <?php
Chris@13 2
Chris@13 3 /*
Chris@13 4 * This file is part of Psy Shell.
Chris@13 5 *
Chris@13 6 * (c) 2012-2018 Justin Hileman
Chris@13 7 *
Chris@13 8 * For the full copyright and license information, please view the LICENSE
Chris@13 9 * file that was distributed with this source code.
Chris@13 10 */
Chris@13 11
Chris@13 12 namespace Psy\Test\Formatter;
Chris@13 13
Chris@13 14 use Psy\Formatter\SignatureFormatter;
Chris@16 15 use Psy\Reflection\ReflectionClassConstant;
Chris@16 16 use Psy\Reflection\ReflectionConstant_;
Chris@13 17
Chris@13 18 class SignatureFormatterTest extends \PHPUnit\Framework\TestCase
Chris@13 19 {
Chris@13 20 const FOO = 'foo value';
Chris@13 21 private static $bar = 'bar value';
Chris@13 22
Chris@13 23 private function someFakeMethod(array $one, $two = 'TWO', \Reflector $three = null)
Chris@13 24 {
Chris@13 25 }
Chris@13 26
Chris@13 27 /**
Chris@13 28 * @dataProvider signatureReflectors
Chris@13 29 */
Chris@13 30 public function testFormat($reflector, $expected)
Chris@13 31 {
Chris@17 32 $this->assertSame($expected, \strip_tags(SignatureFormatter::format($reflector)));
Chris@13 33 }
Chris@13 34
Chris@13 35 public function signatureReflectors()
Chris@13 36 {
Chris@13 37 return [
Chris@13 38 [
Chris@13 39 new \ReflectionFunction('implode'),
Chris@17 40 \defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
Chris@13 41 ],
Chris@13 42 [
Chris@16 43 ReflectionClassConstant::create($this, 'FOO'),
Chris@13 44 'const FOO = "foo value"',
Chris@13 45 ],
Chris@13 46 [
Chris@13 47 new \ReflectionMethod($this, 'someFakeMethod'),
Chris@13 48 'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
Chris@13 49 ],
Chris@13 50 [
Chris@13 51 new \ReflectionProperty($this, 'bar'),
Chris@13 52 'private static $bar',
Chris@13 53 ],
Chris@13 54 [
Chris@13 55 new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
Chris@13 56 'abstract class Psy\CodeCleaner\CodeCleanerPass '
Chris@13 57 . 'extends PhpParser\NodeVisitorAbstract '
Chris@13 58 . 'implements PhpParser\NodeVisitor',
Chris@13 59 ],
Chris@16 60 [
Chris@16 61 new \ReflectionFunction('array_chunk'),
Chris@16 62 'function array_chunk($arg, $size, $preserve_keys = unknown)',
Chris@16 63 ],
Chris@16 64 [
Chris@16 65 new \ReflectionClass('Psy\Test\Formatter\Fixtures\BoringTrait'),
Chris@16 66 'trait Psy\Test\Formatter\Fixtures\BoringTrait',
Chris@16 67 ],
Chris@16 68 [
Chris@16 69 new \ReflectionMethod('Psy\Test\Formatter\Fixtures\BoringTrait', 'boringMethod'),
Chris@16 70 'public function boringMethod($one = 1)',
Chris@16 71 ],
Chris@16 72 [
Chris@16 73 new ReflectionConstant_('E_ERROR'),
Chris@16 74 'define("E_ERROR", 1)',
Chris@16 75 ],
Chris@16 76 [
Chris@16 77 new ReflectionConstant_('PHP_VERSION'),
Chris@16 78 'define("PHP_VERSION", "' . PHP_VERSION . '")',
Chris@16 79 ],
Chris@16 80 [
Chris@16 81 new ReflectionConstant_('__LINE__'),
Chris@16 82 'define("__LINE__", null)', // @todo show this as `unknown` in red or something?
Chris@16 83 ],
Chris@13 84 ];
Chris@13 85 }
Chris@13 86
Chris@13 87 /**
Chris@13 88 * @expectedException \InvalidArgumentException
Chris@13 89 */
Chris@13 90 public function testSignatureFormatterThrowsUnknownReflectorExpeption()
Chris@13 91 {
Chris@13 92 $refl = $this->getMockBuilder('Reflector')->getMock();
Chris@13 93 SignatureFormatter::format($refl);
Chris@13 94 }
Chris@13 95 }