comparison vendor/psy/psysh/test/Formatter/SignatureFormatterTest.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents
children c2387f117808
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
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 }
61
62 /**
63 * @expectedException \InvalidArgumentException
64 */
65 public function testSignatureFormatterThrowsUnknownReflectorExpeption()
66 {
67 $refl = $this->getMockBuilder('Reflector')->getMock();
68 SignatureFormatter::format($refl);
69 }
70 }