Skip to content

Commit

Permalink
Fix up tests and typehints.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 19, 2016
1 parent c0a50db commit 4740108
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 74 deletions.
1 change: 0 additions & 1 deletion src/Http/ActionDispatcher.php
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/Http/ControllerFactory.php
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/Http/Response.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Http/ResponseTransformer.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Server.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/TestSuite/IntegrationTestCase.php
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/TestSuite/MiddlewareDispatcher.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Error/DebuggerTest.php
Expand Up @@ -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 => []
Expand Down
48 changes: 14 additions & 34 deletions tests/TestCase/Network/ResponseTest.php
Expand Up @@ -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;
Expand All @@ -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
*
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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');
Expand All @@ -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');
Expand Down
29 changes: 0 additions & 29 deletions tests/TestCase/Network/mocks.php

This file was deleted.

0 comments on commit 4740108

Please sign in to comment.