Skip to content

Commit 8813eff

Browse files
jrfnlgrogy
authored andcommitted
TokenizeTest: move keyword test case to data provider
1 parent ec2964d commit 8813eff

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

tests/TokenizeTest.php

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -630,37 +630,53 @@ public function dataNameTokens()
630630
return $data;
631631
}
632632

633-
public function testBasicFunction()
633+
/**
634+
* Test the tokenizer and token specific highlighting of keyword and operator tokens.
635+
*
636+
* @dataProvider dataKeywordsAndOperators
637+
*
638+
* @param string $original The input string.
639+
* @param string $expected The expected output string.
640+
*/
641+
public function testKeywordsAndOperators($original, $expected)
642+
{
643+
$this->compare($original, $expected);
644+
}
645+
646+
/**
647+
* Data provider.
648+
*
649+
* @return array
650+
*/
651+
public function dataKeywordsAndOperators()
634652
{
635-
$this->compare(
636-
<<<'EOL'
653+
return array(
654+
'Keywords: instanceof' => array(
655+
'original' => <<<'EOL'
656+
<?php
657+
$a instanceof stdClass;
658+
EOL
659+
,
660+
'expected' => <<<'EOL'
661+
<token_default><?php</token_default>
662+
<token_default>$a </token_default><token_keyword>instanceof </token_keyword><token_default>stdClass</token_default><token_keyword>;</token_keyword>
663+
EOL
664+
),
665+
'Keywords: function, return' => array(
666+
'original' => <<<'EOL'
637667
<?php
638668
function plus($a, $b) {
639669
return $a + $b;
640670
}
641671
EOL
642-
,
643-
<<<'EOL'
672+
,
673+
'expected' => <<<'EOL'
644674
<token_default><?php</token_default>
645675
<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>
646676
<token_keyword> return </token_keyword><token_default>$a </token_default><token_keyword>+ </token_keyword><token_default>$b</token_default><token_keyword>;</token_keyword>
647677
<token_keyword>}</token_keyword>
648678
EOL
649-
);
650-
}
651-
652-
public function testInstanceof()
653-
{
654-
$this->compare(
655-
<<<'EOL'
656-
<?php
657-
$a instanceof stdClass;
658-
EOL
659-
,
660-
<<<'EOL'
661-
<token_default><?php</token_default>
662-
<token_default>$a </token_default><token_keyword>instanceof </token_keyword><token_default>stdClass</token_default><token_keyword>;</token_keyword>
663-
EOL
679+
),
664680
);
665681
}
666682
}

0 commit comments

Comments
 (0)