Browse Source

Merge pull request #9884 from cakephp/3next-move-response

Move Response into Http namespace.
Mark Story 9 years ago
parent
commit
40fb94693c

+ 0 - 1
src/Http/ActionDispatcher.php

@@ -17,7 +17,6 @@ namespace Cake\Http;
 use Cake\Controller\Controller;
 use Cake\Event\EventDispatcherTrait;
 use Cake\Event\EventListenerInterface;
-use Cake\Network\Response;
 use Cake\Routing\Router;
 use LogicException;
 

+ 0 - 1
src/Http/ControllerFactory.php

@@ -15,7 +15,6 @@
 namespace Cake\Http;
 
 use Cake\Core\App;
-use Cake\Network\Response;
 use Cake\Routing\Exception\MissingControllerException;
 use Cake\Utility\Inflector;
 use ReflectionClass;

File diff suppressed because it is too large
+ 2427 - 0
src/Http/Response.php


+ 1 - 1
src/Http/ResponseTransformer.php

@@ -14,7 +14,7 @@
  */
 namespace Cake\Http;
 
-use Cake\Network\Response as CakeResponse;
+use Cake\Http\Response as CakeResponse;
 use Psr\Http\Message\ResponseInterface as PsrResponse;
 use Zend\Diactoros\Response as DiactorosResponse;
 use Zend\Diactoros\Stream;

+ 1 - 1
src/Http/Server.php

@@ -15,7 +15,7 @@
 namespace Cake\Http;
 
 use Cake\Event\EventDispatcherTrait;
-use Cake\Network\Response;
+use Cake\Http\Response;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use RuntimeException;

File diff suppressed because it is too large
+ 2 - 2425
src/Network/Response.php


+ 1 - 1
src/TestSuite/IntegrationTestCase.php

@@ -73,7 +73,7 @@ abstract class IntegrationTestCase extends TestCase
     /**
      * The response for the most recent request.
      *
-     * @var \Cake\Network\Response
+     * @var \Cake\Http\Response
      */
     protected $_response;
 

+ 1 - 2
src/TestSuite/MiddlewareDispatcher.php

@@ -15,7 +15,6 @@ namespace Cake\TestSuite;
 
 use Cake\Core\Configure;
 use Cake\Event\EventManager;
-use Cake\Http\ResponseTransformer;
 use Cake\Http\Server;
 use Cake\Http\ServerRequestFactory;
 use LogicException;
@@ -71,7 +70,7 @@ class MiddlewareDispatcher
      * Run a request and get the response.
      *
      * @param \Cake\Http\ServerRequest $request The request to execute.
-     * @return \Cake\Network\Response The generated response.
+     * @return \Cake\Http\Response The generated response.
      */
     public function execute($request)
     {

+ 1 - 1
tests/TestCase/Error/DebuggerTest.php

@@ -302,7 +302,7 @@ object(Cake\View\View) {
 	hasRendered => false
 	uuids => []
 	request => object(Cake\Http\ServerRequest) {}
-	response => object(Cake\Network\Response) {}
+	response => object(Cake\Http\Response) {}
 	elementCache => 'default'
 	viewClass => null
 	viewVars => []

+ 14 - 34
tests/TestCase/Network/ResponseTest.php

@@ -14,6 +14,8 @@
  */
 namespace Cake\Test\TestCase\Network;
 
+include_once CORE_TEST_CASES . DS . 'Http' . DS . 'server_mocks.php';
+
 use Cake\Network\Exception\NotFoundException;
 use Cake\Network\Request;
 use Cake\Network\Response;
@@ -25,28 +27,6 @@ use Zend\Diactoros\Stream;
  */
 class ResponseTest extends TestCase
 {
-
-    /**
-     * Setup for tests
-     *
-     * @return void
-     */
-    public function setUp()
-    {
-        parent::setUp();
-        include_once __DIR__ . DS . 'mocks.php';
-    }
-
-    /**
-     * Cleanup after tests
-     *
-     * @return void
-     */
-    public function tearDown()
-    {
-        parent::tearDown();
-    }
-
     /**
      * Tests the request object constructor
      *
@@ -313,7 +293,7 @@ class ResponseTest extends TestCase
      */
     public function testSend()
     {
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['_sendHeader', '_sendContent', '_setCookies'])
             ->getMock();
         $response->header([
@@ -438,7 +418,7 @@ class ResponseTest extends TestCase
      */
     public function testSendWithCallableBody()
     {
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['_sendHeader'])
             ->getMock();
         $response->body(function () {
@@ -458,7 +438,7 @@ class ResponseTest extends TestCase
      */
     public function testSendWithCallableBodyWithReturn()
     {
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['_sendHeader'])
             ->getMock();
         $response->body(function () {
@@ -744,7 +724,7 @@ class ResponseTest extends TestCase
      */
     public function testProtocol()
     {
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['_sendHeader', '_sendContent'])
             ->getMock();
         $response->protocol('HTTP/1.0');
@@ -1131,7 +1111,7 @@ class ResponseTest extends TestCase
      */
     public function testNotModified()
     {
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['_sendHeader', '_sendContent'])
             ->getMock();
         $response->body('something');
@@ -1182,7 +1162,7 @@ class ResponseTest extends TestCase
     public function testCheckNotModifiedByEtagStar()
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = '*';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->etag('something');
@@ -1198,7 +1178,7 @@ class ResponseTest extends TestCase
     public function testCheckNotModifiedByEtagExact()
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->etag('something', true);
@@ -1215,7 +1195,7 @@ class ResponseTest extends TestCase
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
         $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->etag('something', true);
@@ -1233,7 +1213,7 @@ class ResponseTest extends TestCase
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
         $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->etag('something', true);
@@ -1251,7 +1231,7 @@ class ResponseTest extends TestCase
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something-else", "other"';
         $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->etag('something', true);
@@ -1268,7 +1248,7 @@ class ResponseTest extends TestCase
     public function testCheckNotModifiedByTime()
     {
         $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->modified('2012-01-01 00:00:00');
@@ -1285,7 +1265,7 @@ class ResponseTest extends TestCase
     {
         $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
         $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
-        $response = $this->getMockBuilder('Cake\Network\Response')
+        $response = $this->getMockBuilder('Cake\Http\Response')
             ->setMethods(['notModified'])
             ->getMock();
         $response->expects($this->never())->method('notModified');

+ 0 - 29
tests/TestCase/Network/mocks.php

@@ -1,29 +0,0 @@
-<?php
-/**
- * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The MIT License
- * For full copyright and license information, please see the LICENSE.txt
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
- * @link          http://cakephp.org CakePHP(tm) Project
- * @since         3.0.0
- * @license       http://www.opensource.org/licenses/mit-license.php MIT License
- */
-
-namespace Cake\Network {
-
-    /**
-     * Mocks the headers_sent() function when invoked from the Cake\Network
-     * namespace so that it always returns false
-     *
-     * @return bool
-     */
-    function headers_sent()
-    {
-        return false;
-    }
-
-}