@@ -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