@@ -20,7 +20,7 @@ class SyntaxErrorGetNormalizeMessageTest extends UnitTestCase
20
20
*
21
21
* @return void
22
22
*/
23
- public function testMessageNormalization ($ message , $ expected )
23
+ public function testMessageNormalizationWithoutTokenTranslation ($ message , $ expected )
24
24
{
25
25
$ error = new SyntaxError ('test.php ' , $ message );
26
26
$ this ->assertSame ($ expected , $ error ->getNormalizedMessage ());
@@ -34,13 +34,35 @@ public function testMessageNormalization($message, $expected)
34
34
public function dataMessageNormalization ()
35
35
{
36
36
return array (
37
- 'Strip leading and trailing information ' => array (
37
+ 'Strip leading and trailing information - fatal error ' => array (
38
38
'message ' => "Fatal error: 'break' not in the 'loop' or 'switch' context in test.php on line 2 " ,
39
39
'expected ' => "'break' not in the 'loop' or 'switch' context " ,
40
40
),
41
+ 'Strip leading and trailing information - parse error ' => array (
42
+ 'message ' => "Parse error: unexpected 'Foo' (T_STRING) in test.php on line 2 " ,
43
+ 'expected ' => "Unexpected 'Foo' (T_STRING) " , // Also verifies ucfirst() call is being made.
44
+ ),
45
+ 'Strip trailing information, not leading - deprecation ' => array (
46
+ 'message ' => "Deprecated: The (real) cast is deprecated, use (float) instead in test.php on line 2 " ,
47
+ 'expected ' => "Deprecated: The (real) cast is deprecated, use (float) instead " ,
48
+ ),
41
49
);
42
50
}
43
51
52
+ /**
53
+ * Test retrieving a normalized error message with token translation.
54
+ *
55
+ * @return void
56
+ */
57
+ public function testMessageNormalizationWithTokenTranslation ()
58
+ {
59
+ $ message = 'Parse error: unexpected T_FILE, expecting T_STRING in test.php on line 2 ' ;
60
+ $ expected = 'Unexpected __FILE__ (T_FILE), expecting T_STRING ' ;
61
+
62
+ $ error = new SyntaxError ('test.php ' , $ message );
63
+ $ this ->assertSame ($ expected , $ error ->getNormalizedMessage (true ));
64
+ }
65
+
44
66
/**
45
67
* Test retrieving a normalized error message with variations for the file path.
46
68
*
0 commit comments