Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/test/Formatter/CodeFormatterTest.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
20 * @dataProvider reflectors | 20 * @dataProvider reflectors |
21 */ | 21 */ |
22 public function testFormat($reflector, $expected) | 22 public function testFormat($reflector, $expected) |
23 { | 23 { |
24 $formatted = CodeFormatter::format($reflector); | 24 $formatted = CodeFormatter::format($reflector); |
25 $formattedWithoutColors = preg_replace('#' . chr(27) . '\[\d\d?m#', '', $formatted); | 25 $formattedWithoutColors = \preg_replace('#' . \chr(27) . '\[\d\d?m#', '', $formatted); |
26 | 26 |
27 $this->assertEquals($expected, self::trimLines($formattedWithoutColors)); | 27 $this->assertEquals($expected, self::trimLines($formattedWithoutColors)); |
28 $this->assertNotEquals($expected, self::trimLines($formatted)); | 28 $this->assertNotEquals($expected, self::trimLines($formatted)); |
29 } | 29 } |
30 | 30 |
86 [new \ReflectionExtension('json')], | 86 [new \ReflectionExtension('json')], |
87 [new \ReflectionParameter(['Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'], 'someParam')], | 87 [new \ReflectionParameter(['Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'], 'someParam')], |
88 [new \ReflectionProperty('Psy\Test\Formatter\Fixtures\SomeClass', 'someProp')], | 88 [new \ReflectionProperty('Psy\Test\Formatter\Fixtures\SomeClass', 'someProp')], |
89 ]; | 89 ]; |
90 | 90 |
91 if (version_compare(PHP_VERSION, '7.1.0', '>=')) { | 91 if (\version_compare(PHP_VERSION, '7.1.0', '>=')) { |
92 $reflectors[] = [new \ReflectionClassConstant('Psy\Test\Formatter\Fixtures\SomeClass', 'SOME_CONST')]; | 92 $reflectors[] = [new \ReflectionClassConstant('Psy\Test\Formatter\Fixtures\SomeClass', 'SOME_CONST')]; |
93 } | 93 } |
94 | 94 |
95 return $reflectors; | 95 return $reflectors; |
96 } | 96 } |
113 CodeFormatter::format($reflector); | 113 CodeFormatter::format($reflector); |
114 } | 114 } |
115 | 115 |
116 public function filenames() | 116 public function filenames() |
117 { | 117 { |
118 if (defined('HHVM_VERSION')) { | 118 if (\defined('HHVM_VERSION')) { |
119 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.'); | 119 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.'); |
120 } | 120 } |
121 | 121 |
122 return [[null], ['not a file']]; | 122 return [[null], ['not a file']]; |
123 } | 123 } |
124 | 124 |
125 private static function trimLines($code) | 125 private static function trimLines($code) |
126 { | 126 { |
127 return rtrim(implode("\n", array_map('rtrim', explode("\n", $code)))); | 127 return \rtrim(\implode("\n", \array_map('rtrim', \explode("\n", $code)))); |
128 } | 128 } |
129 } | 129 } |