Skip to content
Permalink
Browse files

Fix up tests and typehints.

  • Loading branch information...
markstory committed Dec 19, 2016
1 parent c0a50db commit 474010889b14461df004e9a3bd132d89731f49f7
@@ -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;
@@ -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;
@@ -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');
@@ -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;
@@ -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;
@@ -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;
@@ -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)
{
@@ -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 => []
@@ -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');

This file was deleted.

Oops, something went wrong.

0 comments on commit 4740108

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