Skip to content

Commit a0f9331

Browse files
Seldaekfabpot
authored andcommitted
[Console] Fixing tests breaking on windows
1 parent 69d2568 commit a0f9331

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

tests/Symfony/Tests/Component/Console/ApplicationTest.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ static public function setUpBeforeClass()
2828
require_once self::$fixturesPath.'/Foo2Command.php';
2929
}
3030

31+
protected function normalize($text)
32+
{
33+
return str_replace(PHP_EOL, "\n", $text);
34+
}
35+
3136
public function testConstructor()
3237
{
3338
$application = new Application('foo', 'bar');
@@ -198,7 +203,7 @@ public function testSetCatchExceptions()
198203

199204
$application->setCatchExceptions(true);
200205
$tester->run(array('command' => 'foo'));
201-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(), '->setCatchExceptions() sets the catch exception flag');
206+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalize($tester->getDisplay()), '->setCatchExceptions() sets the catch exception flag');
202207

203208
$application->setCatchExceptions(false);
204209
try {
@@ -233,13 +238,13 @@ public function testRenderException()
233238
$tester = new ApplicationTester($application);
234239

235240
$tester->run(array('command' => 'foo'));
236-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(), '->renderException() renders a pretty exception');
241+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalize($tester->getDisplay()), '->renderException() renders a pretty exception');
237242

238243
$tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE));
239-
$this->assertRegExp('/Exception trace/', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
244+
$this->assertRegExp('/Exception trace/', $this->normalize($tester->getDisplay()), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
240245

241246
$tester->run(array('command' => 'list', '--foo' => true));
242-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
247+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $this->normalize($tester->getDisplay()), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
243248
}
244249

245250
public function testRun()
@@ -262,23 +267,23 @@ public function testRun()
262267
$application->setCatchExceptions(false);
263268
$tester = new ApplicationTester($application);
264269
$tester->run(array());
265-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(), '->run() runs the list command if no argument is passed');
270+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $this->normalize($tester->getDisplay()), '->run() runs the list command if no argument is passed');
266271

267272
$tester->run(array('--help' => true));
268-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(), '->run() runs the help command if --help is passed');
273+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if --help is passed');
269274

270275
$tester->run(array('-h' => true));
271-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(), '->run() runs the help command if -h is passed');
276+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if -h is passed');
272277

273278
$application = new Application();
274279
$application->setAutoExit(false);
275280
$application->setCatchExceptions(false);
276281
$tester = new ApplicationTester($application);
277282
$tester->run(array('command' => 'list', '--help' => true));
278-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(), '->run() displays the help if --help is passed');
283+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if --help is passed');
279284

280285
$tester->run(array('command' => 'list', '-h' => true));
281-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(), '->run() displays the help if -h is passed');
286+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if -h is passed');
282287

283288
$application = new Application();
284289
$application->setAutoExit(false);
@@ -295,20 +300,20 @@ public function testRun()
295300
$application->setCatchExceptions(false);
296301
$tester = new ApplicationTester($application);
297302
$tester->run(array('--version' => true));
298-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(), '->run() displays the program version if --version is passed');
303+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if --version is passed');
299304

300305
$tester->run(array('-V' => true));
301-
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(), '->run() displays the program version if -v is passed');
306+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if -v is passed');
302307

303308
$application = new Application();
304309
$application->setAutoExit(false);
305310
$application->setCatchExceptions(false);
306311
$tester = new ApplicationTester($application);
307312
$tester->run(array('command' => 'list', '--quiet' => true));
308-
$this->assertEquals('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
313+
$this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if --quiet is passed');
309314

310315
$tester->run(array('command' => 'list', '-q' => true));
311-
$this->assertEquals('', $tester->getDisplay(), '->run() removes all output if -q is passed');
316+
$this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if -q is passed');
312317

313318
$application = new Application();
314319
$application->setAutoExit(false);
@@ -326,10 +331,10 @@ public function testRun()
326331
$application->addCommand(new \FooCommand());
327332
$tester = new ApplicationTester($application);
328333
$tester->run(array('command' => 'foo:bar', '--no-interaction' => true));
329-
$this->assertEquals("called\n", $tester->getDisplay(), '->run() does not called interact() if --no-interaction is passed');
334+
$this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if --no-interaction is passed');
330335

331336
$tester->run(array('command' => 'foo:bar', '-n' => true));
332-
$this->assertEquals("called\n", $tester->getDisplay(), '->run() does not called interact() if -n is passed');
337+
$this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if -n is passed');
333338
}
334339
}
335340

0 commit comments

Comments
 (0)