From a99723435c85ad68a6127298d974c03eee85859f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 13 Jan 2017 21:12:17 -0500 Subject: [PATCH 1/2] Fix tests in 3.4.0+ Apply patch from @fquffio posted in #471 to fix tests and not break compatibility with <3.4.x. This is a much better fix than the hastily pushed bad change I made last night. --- src/ToolbarService.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ToolbarService.php b/src/ToolbarService.php index 254ca9b6d..5ef998619 100644 --- a/src/ToolbarService.php +++ b/src/ToolbarService.php @@ -210,9 +210,16 @@ public function injectScripts($row, $response) if (strpos($response->type(), 'html') === false) { return $response; } - $body = $response->getBody(); - if (!$body->isSeekable()) { - return $response; + if (method_exists($response, 'getBody')) { + $body = $response->getBody(); + if (!$body->isSeekable()) { + return $response; + } + } else { + $body = $response->body(); + if (!is_string($body)) { + return $response; + } } $pos = strrpos($body, ''); if ($pos === false) { From 1ef730843442352ddc9c53b7e903cc86199469b9 Mon Sep 17 00:00:00 2001 From: antograssiot Date: Sun, 15 Jan 2017 10:10:41 +0100 Subject: [PATCH 2/2] fix tests for PHP5.5 --- tests/TestCase/Routing/Filter/DebugBarFilterTest.php | 6 +++++- tests/TestCase/ToolbarServiceTest.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Routing/Filter/DebugBarFilterTest.php b/tests/TestCase/Routing/Filter/DebugBarFilterTest.php index 25acfbeba..6f75df7d3 100644 --- a/tests/TestCase/Routing/Filter/DebugBarFilterTest.php +++ b/tests/TestCase/Routing/Filter/DebugBarFilterTest.php @@ -136,7 +136,11 @@ public function testAfterDispatchIgnoreStreamBodies() $bar = new DebugBarFilter($this->events, []); $event = new Event('Dispatcher.afterDispatch', $bar, compact('request', 'response')); $bar->afterDispatch($event); - $this->assertEquals('I am a teapot!', $response->body()); + if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + $this->assertEquals('I am a teapot!', $response->body()); + } else { + $this->assertInstanceOf('Closure', $response->body()); + } } /** diff --git a/tests/TestCase/ToolbarServiceTest.php b/tests/TestCase/ToolbarServiceTest.php index 4c147a5c0..2da475e04 100644 --- a/tests/TestCase/ToolbarServiceTest.php +++ b/tests/TestCase/ToolbarServiceTest.php @@ -206,7 +206,11 @@ public function testInjectScriptsStreamBodies() $result = $bar->injectScripts($row, $response); $this->assertInstanceOf('Cake\Network\Response', $result); - $this->assertEquals('I am a teapot!', $result->body()); + if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + $this->assertEquals('I am a teapot!', $response->body()); + } else { + $this->assertInstanceOf('Closure', $response->body()); + } }