Skip to content

Commit cd65082

Browse files
authored
Merge pull request #53 from PHPCSStandards/feature/phpcsdebug-improve-test
PHPCSDebug/Tests: improve further
2 parents 5ce07cc + 3ebc306 commit cd65082

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

PHPCSDebug/Tests/Debug/TokenListUnitTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ class TokenListUnitTest extends UtilityMethodTestCase
3636
*/
3737
public function testOutput()
3838
{
39-
\ob_start();
40-
self::$phpcsFile->process();
41-
$output = \ob_get_flush();
42-
43-
$output = \str_replace(["\r\n", "\r"], "\n", $output);
44-
45-
$this->assertNotEmpty($output);
46-
4739
$expected = "\n";
4840
$expected .= 'Ptr | Ln | Col | Cond | ( #) | Token Type | [len]: Content' . "\n";
4941
$expected .= '-------------------------------------------------------------------------' . "\n";
@@ -52,6 +44,21 @@ public function testOutput()
5244
$expected .= ' 2 | L3 | C 1 | CC 0 | ( 0) | T_FUNCTION | [8]: function' . "\n";
5345
$expected .= ' 3 | L3 | C 9 | CC 0 | ( 0) | T_WHITESPACE | [0]: ' . "\n\n";
5446

55-
$this->assertSame($expected, $output);
47+
$this->expectOutputString($expected);
48+
$this->setOutputCallback([$this, 'normalizeLineEndings']);
49+
50+
self::$phpcsFile->process();
51+
}
52+
53+
/**
54+
* Callback function to normalize line endings in generated output.
55+
*
56+
* @param string $output The output as send to screen.
57+
*
58+
* @return string The output with *nix line endings.
59+
*/
60+
public function normalizeLineEndings($output)
61+
{
62+
return \str_replace(["\r\n", "\r"], "\n", $output);
5663
}
5764
}

0 commit comments

Comments
 (0)