You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TokenizeTest: add additional test cases for text string handling
This adds extra tests for:
* Double quoted strings with interpolated variables.
* Nowdoc
* Heredocs with and without interpolated variables.
Note: for the nowdoc and heredoc tests, the test input is put in single quotes to prevent "nested here/nowdoc", which could skew the tests.
These test cases also need to have a new line after the `;` as otherwise PHP does not tokenize these correctly (and the highlighter is not concerned with fixing incorrect tokenization of PHP itself).
'Double quoted text string with interpolation [1]' => array(
432
+
'original' => <<<'EOL'
433
+
<?php
434
+
echo "Ahoj $text and more text";
435
+
EOL
436
+
,
437
+
'expected' => <<<'EOL'
438
+
<token_default><?php</token_default>
439
+
<token_keyword>echo </token_keyword><token_string>"Ahoj </token_string><token_default>$text</token_default><token_string> and more text"</token_string><token_keyword>;</token_keyword>
440
+
EOL
441
+
),
442
+
'Double quoted text string with interpolation [2]' => array(
443
+
'original' => <<<'EOL'
444
+
<?php
445
+
echo "$text and more text";
446
+
EOL
447
+
,
448
+
'expected' => <<<'EOL'
449
+
<token_default><?php</token_default>
450
+
<token_keyword>echo </token_keyword><token_string>"</token_string><token_default>$text</token_default><token_string> and more text"</token_string><token_keyword>;</token_keyword>
451
+
EOL
452
+
),
453
+
'Double quoted text string with interpolation [3]' => array(
454
+
'original' => <<<'EOL'
455
+
<?php
456
+
echo "Ahoj {$obj->prop} and more text";
457
+
EOL
458
+
,
459
+
'expected' => <<<'EOL'
460
+
<token_default><?php</token_default>
461
+
<token_keyword>echo </token_keyword><token_string>"Ahoj </token_string><token_keyword>{</token_keyword><token_default>$obj</token_default><token_keyword>-></token_keyword><token_default>prop</token_default><token_keyword>}</token_keyword><token_string> and more text"</token_string><token_keyword>;</token_keyword>
0 commit comments