comparison vendor/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.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 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
1 <?php 1 <?php declare(strict_types=1);
2 2
3 namespace PhpParser\Node\Scalar; 3 namespace PhpParser\Node\Scalar;
4 4
5 class StringTest extends \PHPUnit_Framework_TestCase 5 use PHPUnit\Framework\TestCase;
6
7 class StringTest extends TestCase
6 { 8 {
7 /** 9 /**
8 * @dataProvider provideTestParseEscapeSequences 10 * @dataProvider provideTestParseEscapeSequences
9 */ 11 */
10 public function testParseEscapeSequences($expected, $string, $quote) { 12 public function testParseEscapeSequences($expected, $string, $quote) {
23 String_::parse($string) 25 String_::parse($string)
24 ); 26 );
25 } 27 }
26 28
27 public function provideTestParseEscapeSequences() { 29 public function provideTestParseEscapeSequences() {
28 return array( 30 return [
29 array('"', '\\"', '"'), 31 ['"', '\\"', '"'],
30 array('\\"', '\\"', '`'), 32 ['\\"', '\\"', '`'],
31 array('\\"\\`', '\\"\\`', null), 33 ['\\"\\`', '\\"\\`', null],
32 array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null), 34 ["\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null],
33 array("\x1B", '\e', null), 35 ["\x1B", '\e', null],
34 array(chr(255), '\xFF', null), 36 [chr(255), '\xFF', null],
35 array(chr(255), '\377', null), 37 [chr(255), '\377', null],
36 array(chr(0), '\400', null), 38 [chr(0), '\400', null],
37 array("\0", '\0', null), 39 ["\0", '\0', null],
38 array('\xFF', '\\\\xFF', null), 40 ['\xFF', '\\\\xFF', null],
39 ); 41 ];
40 } 42 }
41 43
42 public function provideTestParse() { 44 public function provideTestParse() {
43 $tests = array( 45 $tests = [
44 array('A', '\'A\''), 46 ['A', '\'A\''],
45 array('A', 'b\'A\''), 47 ['A', 'b\'A\''],
46 array('A', '"A"'), 48 ['A', '"A"'],
47 array('A', 'b"A"'), 49 ['A', 'b"A"'],
48 array('\\', '\'\\\\\''), 50 ['\\', '\'\\\\\''],
49 array('\'', '\'\\\'\''), 51 ['\'', '\'\\\'\''],
50 ); 52 ];
51 53
52 foreach ($this->provideTestParseEscapeSequences() as $i => $test) { 54 foreach ($this->provideTestParseEscapeSequences() as $i => $test) {
53 // skip second and third tests, they aren't for double quotes 55 // skip second and third tests, they aren't for double quotes
54 if ($i != 1 && $i != 2) { 56 if ($i !== 1 && $i !== 2) {
55 $tests[] = array($test[0], '"' . $test[1] . '"'); 57 $tests[] = [$test[0], '"' . $test[1] . '"'];
56 } 58 }
57 } 59 }
58 60
59 return $tests; 61 return $tests;
60 } 62 }