Browse Source

Fix Response __debugInfo() to get body content

Michael Hoffmann 8 years ago
parent
commit
7ee9d21b2a
2 changed files with 3 additions and 2 deletions
  1. 1 1
      src/Http/Response.php
  2. 2 1
      tests/TestCase/Http/ResponseTest.php

+ 1 - 1
src/Http/Response.php

@@ -2589,7 +2589,7 @@ class Response implements ResponseInterface
             'fileRange' => $this->_fileRange,
             'cookies' => $this->_cookies,
             'cacheDirectives' => $this->_cacheDirectives,
-            'body' => $this->getBody()->getContents(),
+            'body' => (string)$this->getBody(),
         ];
     }
 }

+ 2 - 1
tests/TestCase/Http/ResponseTest.php

@@ -3137,6 +3137,7 @@ class ResponseTest extends TestCase
     public function testDebugInfo()
     {
         $response = new Response();
+        $response = $response->withStringBody('Foo');
         $result = $response->__debugInfo();
 
         $expected = [
@@ -3149,7 +3150,7 @@ class ResponseTest extends TestCase
             'fileRange' => [],
             'cookies' => new CookieCollection(),
             'cacheDirectives' => [],
-            'body' => ''
+            'body' => 'Foo'
         ];
         $this->assertEquals($expected, $result);
     }