comparison vendor/psy/psysh/test/Formatter/CodeFormatterTest.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\CodeFormatter;
15
16 class CodeFormatterTest extends \PHPUnit\Framework\TestCase
17 {
18 private function ignoreThisMethod($arg)
19 {
20 echo 'whot!';
21 }
22
23 public function testFormat()
24 {
25 $expected = <<<'EOS'
26 > 18| private function ignoreThisMethod($arg)
27 19| {
28 20| echo 'whot!';
29 21| }
30 EOS;
31
32 $formatted = CodeFormatter::format(new \ReflectionMethod($this, 'ignoreThisMethod'));
33 $formattedWithoutColors = preg_replace('#' . chr(27) . '\[\d\d?m#', '', $formatted);
34
35 $this->assertEquals($expected, rtrim($formattedWithoutColors));
36 $this->assertNotEquals($expected, rtrim($formatted));
37 }
38
39 /**
40 * @dataProvider filenames
41 * @expectedException \Psy\Exception\RuntimeException
42 */
43 public function testCodeFormatterThrowsException($filename)
44 {
45 $reflector = $this->getMockBuilder('ReflectionClass')
46 ->disableOriginalConstructor()
47 ->getMock();
48
49 $reflector
50 ->expects($this->once())
51 ->method('getFileName')
52 ->will($this->returnValue($filename));
53
54 CodeFormatter::format($reflector);
55 }
56
57 public function filenames()
58 {
59 if (defined('HHVM_VERSION')) {
60 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.');
61 }
62
63 return [[null], ['not a file']];
64 }
65 }