Skip to content

Commit 0affaef

Browse files
authored
Merge pull request #477 from cakephp/fix-tests
Fix tests in 3.4.0+
2 parents 5e48c05 + 1ef7308 commit 0affaef

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/ToolbarService.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,16 @@ public function injectScripts($row, $response)
210210
if (strpos($response->type(), 'html') === false) {
211211
return $response;
212212
}
213-
$body = $response->getBody();
214-
if (!$body->isSeekable()) {
215-
return $response;
213+
if (method_exists($response, 'getBody')) {
214+
$body = $response->getBody();
215+
if (!$body->isSeekable()) {
216+
return $response;
217+
}
218+
} else {
219+
$body = $response->body();
220+
if (!is_string($body)) {
221+
return $response;
222+
}
216223
}
217224
$pos = strrpos($body, '</body>');
218225
if ($pos === false) {

tests/TestCase/Routing/Filter/DebugBarFilterTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ public function testAfterDispatchIgnoreStreamBodies()
136136
$bar = new DebugBarFilter($this->events, []);
137137
$event = new Event('Dispatcher.afterDispatch', $bar, compact('request', 'response'));
138138
$bar->afterDispatch($event);
139-
$this->assertEquals('I am a teapot!', $response->body());
139+
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
140+
$this->assertEquals('I am a teapot!', $response->body());
141+
} else {
142+
$this->assertInstanceOf('Closure', $response->body());
143+
}
140144
}
141145

142146
/**

tests/TestCase/ToolbarServiceTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ public function testInjectScriptsStreamBodies()
206206

207207
$result = $bar->injectScripts($row, $response);
208208
$this->assertInstanceOf('Cake\Network\Response', $result);
209-
$this->assertEquals('I am a teapot!', $result->body());
209+
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
210+
$this->assertEquals('I am a teapot!', $response->body());
211+
} else {
212+
$this->assertInstanceOf('Closure', $response->body());
213+
}
210214
}
211215

212216

0 commit comments

Comments
 (0)