diff --git a/src/Http/ActionDispatcher.php b/src/Http/ActionDispatcher.php index 19a333986a2..f8691166480 100644 --- a/src/Http/ActionDispatcher.php +++ b/src/Http/ActionDispatcher.php @@ -17,7 +17,6 @@ use Cake\Controller\Controller; use Cake\Event\EventDispatcherTrait; use Cake\Event\EventListenerInterface; -use Cake\Network\Response; use Cake\Routing\Router; use LogicException; diff --git a/src/Http/ControllerFactory.php b/src/Http/ControllerFactory.php index a38281ee4cc..aad6136a8e8 100644 --- a/src/Http/ControllerFactory.php +++ b/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; diff --git a/src/Http/Response.php b/src/Http/Response.php index 7449d058cde..d4eb673e79b 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -12,12 +12,13 @@ * @since 2.0.0 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -namespace Cake\Network; +namespace Cake\Http; use Cake\Core\Configure; use Cake\Filesystem\File; use Cake\Http\CallbackStream; use Cake\Log\Log; +use Cake\Network\CorsBuilder; use Cake\Network\Exception\NotFoundException; use DateTime; use DateTimeZone; @@ -1850,7 +1851,7 @@ public function withLength($bytes) * @param \Cake\Http\ServerRequest $request Request object * @return bool Whether the response was marked as not modified or not. */ - public function checkNotModified(Request $request) + public function checkNotModified(ServerRequest $request) { $etags = preg_split('/\s*,\s*/', $request->header('If-None-Match'), null, PREG_SPLIT_NO_EMPTY); $modifiedSince = $request->header('If-Modified-Since'); @@ -2061,7 +2062,7 @@ public function getCookie($name) * @return \Cake\Network\CorsBuilder A builder object the provides a fluent interface for defining * additional CORS headers. */ - public function cors(Request $request, $allowedDomains = [], $allowedMethods = [], $allowedHeaders = []) + public function cors(ServerRequest $request, $allowedDomains = [], $allowedMethods = [], $allowedHeaders = []) { $origin = $request->header('Origin'); $ssl = $request->is('ssl'); diff --git a/src/Http/ResponseTransformer.php b/src/Http/ResponseTransformer.php index 7e63391ce1c..a2aae538b4d 100644 --- a/src/Http/ResponseTransformer.php +++ b/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; diff --git a/src/Http/Server.php b/src/Http/Server.php index 98a19488661..ff11cc81c9d 100644 --- a/src/Http/Server.php +++ b/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; diff --git a/src/TestSuite/IntegrationTestCase.php b/src/TestSuite/IntegrationTestCase.php index 4c7a25b357c..6edbb896289 100644 --- a/src/TestSuite/IntegrationTestCase.php +++ b/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; diff --git a/src/TestSuite/MiddlewareDispatcher.php b/src/TestSuite/MiddlewareDispatcher.php index 264ee9de98c..3c9cb409c90 100644 --- a/src/TestSuite/MiddlewareDispatcher.php +++ b/src/TestSuite/MiddlewareDispatcher.php @@ -15,7 +15,6 @@ 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 @@ public function __construct($test, $class = null, $constructorArgs = null) * 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) { diff --git a/tests/TestCase/Error/DebuggerTest.php b/tests/TestCase/Error/DebuggerTest.php index d63a2026628..63f675b3d18 100644 --- a/tests/TestCase/Error/DebuggerTest.php +++ b/tests/TestCase/Error/DebuggerTest.php @@ -302,7 +302,7 @@ public function testExportVar() hasRendered => false uuids => [] request => object(Cake\Http\ServerRequest) {} - response => object(Cake\Network\Response) {} + response => object(Cake\Http\Response) {} elementCache => 'default' viewClass => null viewVars => [] diff --git a/tests/TestCase/Network/ResponseTest.php b/tests/TestCase/Network/ResponseTest.php index 4a13bbeb172..6efdb660752 100644 --- a/tests/TestCase/Network/ResponseTest.php +++ b/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 @@ */ 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 @@ public function testHeader() */ 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 @@ public function testStatusClearsContentType() */ 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 @@ public function testSendWithCallableBody() */ 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 @@ public function testOutputCompressed() */ 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 @@ public function testWithEtag() */ 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 @@ public function testWithNotModified() 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 @@ public function testCheckNotModifiedByEtagStar() 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 @@ public function testCheckNotModifiedByEtagAndTime() { $_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 @@ public function testCheckNotModifiedByEtagAndTimeMismatch() { $_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 @@ public function testCheckNotModifiedByEtagMismatch() { $_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 @@ public function testCheckNotModifiedByEtagMismatch() 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 @@ public function testCheckNotModifiedNoHints() { $_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'); diff --git a/tests/TestCase/Network/mocks.php b/tests/TestCase/Network/mocks.php deleted file mode 100644 index fe625d1db97..00000000000 --- a/tests/TestCase/Network/mocks.php +++ /dev/null @@ -1,29 +0,0 @@ -