From 4cbf3a8bda6b4b3c1cae708790fdcce49a63fba8 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Sat, 12 Dec 2015 22:11:11 +0200 Subject: [PATCH] Fix flaky PlainTextHandler tests by replacing exact matching of strings --- tests/Whoops/Handler/PlainTextHandlerTest.php | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/Whoops/Handler/PlainTextHandlerTest.php b/tests/Whoops/Handler/PlainTextHandlerTest.php index 397187b..6ea342b 100644 --- a/tests/Whoops/Handler/PlainTextHandlerTest.php +++ b/tests/Whoops/Handler/PlainTextHandlerTest.php @@ -229,13 +229,11 @@ class PlainTextHandlerTest extends TestCase $loggerOnly = false ); - $lines = explode("\n", $text); - // Check that the response has the correct value: - $this->assertEquals('Stack trace:', $lines[1]); + $this->assertContains('Stack trace:', $text); // Check that the trace is returned: - $this->assertEquals( + $this->assertContains( sprintf( '%3d. %s->%s() %s:%d', 2, @@ -244,7 +242,7 @@ class PlainTextHandlerTest extends TestCase __FILE__, 55 ), - $lines[3] + $text ); } @@ -271,10 +269,10 @@ class PlainTextHandlerTest extends TestCase $this->assertGreaterThan(60, count($lines)); // Check that the response has the correct value: - $this->assertEquals('Stack trace:', $lines[1]); + $this->assertContains('Stack trace:', $text); // Check that the trace is returned: - $this->assertEquals( + $this->assertContains( sprintf( '%3d. %s->%s() %s:%d', 2, @@ -283,15 +281,15 @@ class PlainTextHandlerTest extends TestCase __FILE__, 55 ), - $lines[8] + $text ); // Check that the trace arguments are returned: - $this->assertEquals(sprintf( + $this->assertContains(sprintf( '%s string(%d) "%s"', PlainTextHandler::VAR_DUMP_PREFIX, strlen('test message'), 'test message' - ), $lines[5] + ), $text ); } @@ -312,13 +310,11 @@ class PlainTextHandlerTest extends TestCase $loggerOnly = false ); - $lines = explode("\n", $text); - // Check that the response has the correct value: - $this->assertEquals('Stack trace:', $lines[1]); + $this->assertContains('Stack trace:', $text); // Check that the trace is returned: - $this->assertEquals( + $this->assertContains( sprintf( '%3d. %s->%s() %s:%d', 2, @@ -327,16 +323,16 @@ class PlainTextHandlerTest extends TestCase __FILE__, 55 ), - $lines[8] + $text ); // Check that the trace arguments are returned: - $this->assertEquals(sprintf( + $this->assertContains(sprintf( '%s string(%d) "%s"', PlainTextHandler::VAR_DUMP_PREFIX, strlen('test message'), 'test message' - ), $lines[5] + ), $text ); }