Skip to content

Commit

Permalink
Merge pull request #477 from cakephp/fix-tests
Browse files Browse the repository at this point in the history
Fix tests in 3.4.0+
  • Loading branch information
lorenzo authored Jan 15, 2017
2 parents 5e48c05 + 1ef7308 commit 0affaef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/ToolbarService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '</body>');
if ($pos === false) {
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/Routing/Filter/DebugBarFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/ToolbarServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}


Expand Down

0 comments on commit 0affaef

Please sign in to comment.