Skip to content

Commit aa233c8

Browse files
jrfnlgrogy
authored andcommitted
TokenizeTest: move text string test cases to data provider
1 parent a2a2006 commit aa233c8

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

tests/TokenizeTest.php

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -385,51 +385,67 @@ public function dataComments()
385385
);
386386
}
387387

388-
public function testBasicFunction()
388+
/**
389+
* Test the tokenizer and token specific highlighting of text string tokens.
390+
*
391+
* @dataProvider dataTextStrings
392+
*
393+
* @param string $original The input string.
394+
* @param string $expected The expected output string.
395+
*/
396+
public function testTextStrings($original, $expected)
389397
{
390-
$this->compare(
391-
<<<'EOL'
392-
<?php
393-
function plus($a, $b) {
394-
return $a + $b;
395-
}
396-
EOL
397-
,
398-
<<<'EOL'
399-
<token_default><?php</token_default>
400-
<token_keyword>function </token_keyword><token_default>plus</token_default><token_keyword>(</token_keyword><token_default>$a</token_default><token_keyword>, </token_keyword><token_default>$b</token_default><token_keyword>) {</token_keyword>
401-
<token_keyword> return </token_keyword><token_default>$a </token_default><token_keyword>+ </token_keyword><token_default>$b</token_default><token_keyword>;</token_keyword>
402-
<token_keyword>}</token_keyword>
403-
EOL
404-
);
398+
$this->compare($original, $expected);
405399
}
406400

407-
public function testStringNormal()
401+
/**
402+
* Data provider for testing text string tokens.
403+
*
404+
* @return array
405+
*/
406+
public function dataTextStrings()
408407
{
409-
$this->compare(
410-
<<<'EOL'
408+
return array(
409+
'Single quoted text string' => array(
410+
'original' => <<<'EOL'
411411
<?php
412412
echo 'Ahoj světe';
413413
EOL
414-
,
415-
<<<'EOL'
414+
,
415+
'expected' => <<<'EOL'
416416
<token_default><?php</token_default>
417417
<token_keyword>echo </token_keyword><token_string>'Ahoj světe'</token_string><token_keyword>;</token_keyword>
418418
EOL
419+
),
420+
'Double quoted text string' => array(
421+
'original' => <<<'EOL'
422+
<?php
423+
echo "Ahoj světe";
424+
EOL
425+
,
426+
'expected' => <<<'EOL'
427+
<token_default><?php</token_default>
428+
<token_keyword>echo </token_keyword><token_string>"Ahoj světe"</token_string><token_keyword>;</token_keyword>
429+
EOL
430+
),
419431
);
420432
}
421433

422-
public function testStringDouble()
434+
public function testBasicFunction()
423435
{
424436
$this->compare(
425437
<<<'EOL'
426438
<?php
427-
echo "Ahoj světe";
439+
function plus($a, $b) {
440+
return $a + $b;
441+
}
428442
EOL
429443
,
430444
<<<'EOL'
431445
<token_default><?php</token_default>
432-
<token_keyword>echo </token_keyword><token_string>"Ahoj světe"</token_string><token_keyword>;</token_keyword>
446+
<token_keyword>function </token_keyword><token_default>plus</token_default><token_keyword>(</token_keyword><token_default>$a</token_default><token_keyword>, </token_keyword><token_default>$b</token_default><token_keyword>) {</token_keyword>
447+
<token_keyword> return </token_keyword><token_default>$a </token_default><token_keyword>+ </token_keyword><token_default>$b</token_default><token_keyword>;</token_keyword>
448+
<token_keyword>}</token_keyword>
433449
EOL
434450
);
435451
}

0 commit comments

Comments
 (0)