Skip to content

Commit 769f5ac

Browse files
jrfnlgrogy
authored andcommitted
Tests: make dataproviders static
As of PHPUnit 10, data providers are (again) expected to be `static` methods. This updates the test suite to respect that. Includes removing the use of `$this` from select data providers. Refs: * sebastianbergmann/phpunit@9caafe2 * sebastianbergmann/phpunit 5100
1 parent 9f2d6cc commit 769f5ac

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

tests/ColorLinesTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ColorLinesTest extends HighlighterTestCase
1313
{
1414
/** @var string */
15-
private $input = array(
15+
private static $input = array(
1616
7 => array (
1717
0 => array (
1818
0 => 'token_keyword',
@@ -70,22 +70,22 @@ public function testColorLines($input, $expected, $withTheme = true)
7070
*
7171
* @return array
7272
*/
73-
public function dataColorLines()
73+
public static function dataColorLines()
7474
{
7575
return array(
7676
'No lines' => array(
7777
'input' => array(),
7878
'expected' => array(),
7979
),
8080
'With theme' => array(
81-
'input' => $this->input,
81+
'input' => self::$input,
8282
'expected' => array(
8383
7 => '<token_keyword>function </token_keyword><token_default>bar</token_default><token_keyword>(</token_keyword><token_default>$param</token_default><token_unknown>) </token_unknown><token_keyword>{}</token_keyword>',
8484
),
8585
'withTheme' => true,
8686
),
8787
'Without theme' => array(
88-
'input' => $this->input,
88+
'input' => self::$input,
8989
'expected' => array(
9090
7 => 'function bar($param) {}',
9191
),
@@ -110,7 +110,7 @@ public function testColorLinesWithRealColors()
110110
$method->setAccessible(true);
111111

112112
$highlighter = new Highlighter($color);
113-
$output = $method->invoke($highlighter, $this->input);
113+
$output = $method->invoke($highlighter, self::$input);
114114
$method->setAccessible(false);
115115

116116
$this->assertSame($expected, $output);

tests/GetCodeSnippetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testGetCodeSnippet($expected, $lineNo, $linesBeforeAfter = 2)
5757
*
5858
* @return array
5959
*/
60-
public function dataGetCodeSnippet()
60+
public static function dataGetCodeSnippet()
6161
{
6262
return array(
6363
'Snippet at start of code - line 1' => array(

tests/GetWholeFileTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GetWholeFileTest extends HighlighterTestCase
1414
private $highlighter;
1515

1616
/** @var string */
17-
private $input = <<<'EOL'
17+
private static $input = <<<'EOL'
1818
<?php
1919
2020
namespace FooBar;
@@ -68,7 +68,7 @@ public function testGetWholeFile($input, $expected)
6868
*
6969
* @return array
7070
*/
71-
public function dataGetWholeFile()
71+
public static function dataGetWholeFile()
7272
{
7373
return array(
7474
'Empty source' => array(
@@ -85,7 +85,7 @@ public function dataGetWholeFile()
8585
EOL
8686
),
8787
'Multi-line' => array(
88-
'input' => $this->input,
88+
'input' => self::$input,
8989
'expected' => <<<'EOL'
9090
<token_default><?php</token_default>
9191
@@ -135,7 +135,7 @@ public function testGetWholeFileWithLineNumbers()
135135
<line_number>15| </line_number><token_default>?></token_default>
136136
EOL;
137137

138-
$output = $this->highlighter->getWholeFileWithLineNumbers($this->input);
138+
$output = $this->highlighter->getWholeFileWithLineNumbers(self::$input);
139139
// Allow unit tests to succeed on non-*nix systems.
140140
$output = str_replace(array("\r\n", "\r"), "\n", $output);
141141

tests/TokenizeTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testEmptyFiles($original, $expected)
6161
*
6262
* @return array
6363
*/
64-
public function dataEmptyFiles()
64+
public static function dataEmptyFiles()
6565
{
6666
return array(
6767
'Empty file' => array(
@@ -93,7 +93,7 @@ public function testPhpTags($original, $expected)
9393
*
9494
* @return array
9595
*/
96-
public function dataPhpTags()
96+
public static function dataPhpTags()
9797
{
9898
return array(
9999
'"Long" open tag with close tag' => array(
@@ -135,7 +135,7 @@ public function testMagicConstants($original, $expected)
135135
*
136136
* @return array
137137
*/
138-
public function dataMagicConstants()
138+
public static function dataMagicConstants()
139139
{
140140
$magicConstants = array(
141141
'__FILE__',
@@ -184,7 +184,7 @@ public function testMiscTokens($original, $expected)
184184
*
185185
* @return array
186186
*/
187-
public function dataMiscTokens()
187+
public static function dataMiscTokens()
188188
{
189189
return array(
190190
'Constant (T_STRING)' => array(
@@ -263,7 +263,7 @@ public function testComments($original, $expected)
263263
*
264264
* @return array
265265
*/
266-
public function dataComments()
266+
public static function dataComments()
267267
{
268268
return array(
269269
'Doc block: single line' => array(
@@ -378,7 +378,7 @@ public function testTextStrings($original, $expected)
378378
*
379379
* @return array
380380
*/
381-
public function dataTextStrings()
381+
public static function dataTextStrings()
382382
{
383383
return array(
384384
'Single quoted text string' => array(
@@ -499,7 +499,7 @@ public function testInlineHtml($original, $expected)
499499
*
500500
* @return array
501501
*/
502-
public function dataInlineHtml()
502+
public static function dataInlineHtml()
503503
{
504504
return array(
505505
'Inline HTML' => array(
@@ -532,7 +532,7 @@ public function testNameTokens($original, $expected)
532532
*
533533
* @return array
534534
*/
535-
public function dataNameTokens()
535+
public static function dataNameTokens()
536536
{
537537
$data = array(
538538
'Unqualified function call' => array(
@@ -623,7 +623,7 @@ public function testKeywordsAndOperators($original, $expected)
623623
*
624624
* @return array
625625
*/
626-
public function dataKeywordsAndOperators()
626+
public static function dataKeywordsAndOperators()
627627
{
628628
return array(
629629
'Keywords: instanceof' => array(

0 commit comments

Comments
 (0)