Skip to content
Permalink
Browse files

Fix incorrect triggering of callable strings

  • Loading branch information...
chinpei215 committed Dec 4, 2017
1 parent 3bf426d commit c68a773912328bd9684d89988a952cafb8eca157
Showing with 18 additions and 1 deletion.
  1. +1 −1 src/Http/Response.php
  2. +17 −0 tests/TestCase/Http/ResponseTest.php
@@ -828,7 +828,7 @@ public function body($content = null)
}
// Compatibility with closure/streaming responses
if (is_callable($content)) {
if (!is_string($content) && is_callable($content)) {
$this->stream = new CallbackStream($content);
} else {
$this->_createStream();
@@ -521,6 +521,23 @@ public function testSendWithCallableBodyWithReturn()
$this->assertEquals('the response body', ob_get_clean());
}
/**
* Tests that callable strings are not triggered
*
* @return void
*/
public function testSendWithCallableStringBody()
{
$response = $this->getMockBuilder('Cake\Http\Response')
->setMethods(['_sendHeader'])
->getMock();
$response->body('phpversion');
ob_start();
$response->send();
$this->assertEquals('phpversion', ob_get_clean());
}
/**
* Tests the disableCache method
*

0 comments on commit c68a773

Please sign in to comment.
You can’t perform that action at this time.