@@ -18,22 +18,26 @@ class BackfillExplicitOctalNotationTest extends AbstractMethodUnitTest
1818 /**
1919 * Test that explicitly-defined octal values are tokenized as a single number and not as a number and a string.
2020 *
21- * @param array $testData The data required for the specific test case.
21+ * @param string $marker The comment which prefaces the target token in the test file.
22+ * @param string $value The expected content of the token
23+ * @param int|string $nextToken The expected next token.
24+ * @param string $nextContent The expected content of the next token.
2225 *
2326 * @dataProvider dataExplicitOctalNotation
2427 * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
2528 *
2629 * @return void
2730 */
28- public function testExplicitOctalNotation ($ testData )
31+ public function testExplicitOctalNotation ($ marker , $ value , $ nextToken , $ nextContent )
2932 {
3033 $ tokens = self ::$ phpcsFile ->getTokens ();
3134
32- $ number = $ this ->getTargetToken ($ testData [ ' marker ' ] , [T_LNUMBER ]);
35+ $ number = $ this ->getTargetToken ($ marker , [T_LNUMBER ]);
3336
34- $ this ->assertSame (constant ($ testData ['type ' ]), $ tokens [$ number ]['code ' ]);
35- $ this ->assertSame ($ testData ['type ' ], $ tokens [$ number ]['type ' ]);
36- $ this ->assertSame ($ testData ['value ' ], $ tokens [$ number ]['content ' ]);
37+ $ this ->assertSame ($ value , $ tokens [$ number ]['content ' ], 'Content of integer token does not match expectation ' );
38+
39+ $ this ->assertSame ($ nextToken , $ tokens [($ number + 1 )]['code ' ], 'Next token is not the expected type, but ' .$ tokens [($ number + 1 )]['type ' ]);
40+ $ this ->assertSame ($ nextContent , $ tokens [($ number + 1 )]['content ' ], 'Next token did not have the expected contents ' );
3741
3842 }//end testExplicitOctalNotation()
3943
@@ -49,67 +53,58 @@ public function dataExplicitOctalNotation()
4953 {
5054 return [
5155 [
52- [
53- 'marker ' => '/* testExplicitOctal */ ' ,
54- 'type ' => 'T_LNUMBER ' ,
55- 'value ' => '0o137041 ' ,
56- ],
56+ 'marker ' => '/* testExplicitOctal */ ' ,
57+ 'value ' => '0o137041 ' ,
58+ 'nextToken ' => T_SEMICOLON ,
59+ 'nextContent ' => '; ' ,
5760 ],
5861 [
59- [
60- 'marker ' => '/* testExplicitOctalCapitalised */ ' ,
61- 'type ' => 'T_LNUMBER ' ,
62- 'value ' => '0O137041 ' ,
63- ],
62+ 'marker ' => '/* testExplicitOctalCapitalised */ ' ,
63+ 'value ' => '0O137041 ' ,
64+ 'nextToken ' => T_SEMICOLON ,
65+ 'nextContent ' => '; ' ,
6466 ],
6567 [
66- [
67- 'marker ' => '/* testExplicitOctalWithNumericSeparator */ ' ,
68- 'type ' => 'T_LNUMBER ' ,
69- 'value ' => '0o137_041 ' ,
70- ],
68+ 'marker ' => '/* testExplicitOctalWithNumericSeparator */ ' ,
69+ 'value ' => '0o137_041 ' ,
70+ 'nextToken ' => T_SEMICOLON ,
71+ 'nextContent ' => '; ' ,
7172 ],
7273 [
73- [
74- 'marker ' => '/* testInvalid1 */ ' ,
75- 'type ' => 'T_LNUMBER ' ,
76- 'value ' => '0 ' ,
77- ],
74+ 'marker ' => '/* testInvalid1 */ ' ,
75+ 'value ' => '0 ' ,
76+ 'nextToken ' => T_STRING ,
77+ 'nextContent ' => 'o_137 ' ,
7878 ],
7979 [
80- [
81- 'marker ' => '/* testInvalid2 */ ' ,
82- 'type ' => 'T_LNUMBER ' ,
83- 'value ' => '0 ' ,
84- ],
80+ 'marker ' => '/* testInvalid2 */ ' ,
81+ 'value ' => '0 ' ,
82+ 'nextToken ' => T_STRING ,
83+ 'nextContent ' => 'O_41 ' ,
8584 ],
8685 [
87- [
88- 'marker ' => '/* testInvalid3 */ ' ,
89- 'type ' => 'T_LNUMBER ' ,
90- 'value ' => '0 ' ,
91- ],
86+ 'marker ' => '/* testInvalid3 */ ' ,
87+ 'value ' => '0 ' ,
88+ 'nextToken ' => T_STRING ,
89+ 'nextContent ' => 'o91 ' ,
9290 ],
9391 [
94- [
95- 'marker ' => '/* testInvalid4 */ ' ,
96- 'type ' => 'T_LNUMBER ' ,
97- 'value ' => '0O2 ' ,
98- ],
92+ 'marker ' => '/* testInvalid4 */ ' ,
93+ 'value ' => '0O2 ' ,
94+ 'nextToken ' => T_LNUMBER ,
95+ 'nextContent ' => '82 ' ,
9996 ],
10097 [
101- [
102- 'marker ' => '/* testInvalid5 */ ' ,
103- 'type ' => 'T_LNUMBER ' ,
104- 'value ' => '0o2 ' ,
105- ],
98+ 'marker ' => '/* testInvalid5 */ ' ,
99+ 'value ' => '0o2 ' ,
100+ 'nextToken ' => T_LNUMBER ,
101+ 'nextContent ' => '8_2 ' ,
106102 ],
107103 [
108- [
109- 'marker ' => '/* testInvalid6 */ ' ,
110- 'type ' => 'T_LNUMBER ' ,
111- 'value ' => '0o2 ' ,
112- ],
104+ 'marker ' => '/* testInvalid6 */ ' ,
105+ 'value ' => '0o2 ' ,
106+ 'nextToken ' => T_STRING ,
107+ 'nextContent ' => '_82 ' ,
113108 ],
114109 ];
115110
0 commit comments