Skip to content
Permalink
Browse files

Remove use of TestCase::getMock() from "Routing" namepace tests.

  • Loading branch information...
ADmad committed Jun 5, 2016
1 parent 07e390b commit 893358fa3b9ada227be3f162c7fce4e697de446c
@@ -41,7 +41,9 @@ public function setUp()
*/
public function testAddFilter()
{
$mw = $this->getMock('Cake\Routing\DispatcherFilter', ['beforeDispatch']);
$mw = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch'])
->getMock();
$result = DispatcherFactory::add($mw);
$this->assertSame($mw, $result);
}
@@ -89,7 +91,9 @@ public function testAddFilterWithOptions()
*/
public function testCreate()
{
$mw = $this->getMock('Cake\Routing\DispatcherFilter', ['beforeDispatch']);
$mw = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch'])
->getMock();
DispatcherFactory::add($mw);
$result = DispatcherFactory::create();
$this->assertInstanceOf('Cake\Routing\Dispatcher', $result);
@@ -179,7 +179,9 @@ public function testImplementedEventsMethodName()
$beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('response', 'request'));
$afterEvent = new Event('Dispatcher.afterDispatch', $this, compact('response', 'request'));
$filter = $this->getMock('Cake\Routing\DispatcherFilter', ['beforeDispatch', 'afterDispatch']);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch', 'afterDispatch'])
->getMock();
$filter->expects($this->at(0))
->method('beforeDispatch')
->with($beforeEvent);
@@ -204,11 +206,10 @@ public function testHandleAppliesFor()
$event = new Event('Dispatcher.beforeDispatch', $this, compact('response', 'request'));
$filter = $this->getMock(
'Cake\Routing\DispatcherFilter',
['beforeDispatch'],
[['for' => '/admin']]
);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch'])
->setConstructorArgs([['for' => '/admin']])
->getMock();
$filter->expects($this->never())
->method('beforeDispatch');
@@ -231,11 +232,10 @@ public function testHandleAppliesWhen()
return false;
};
$filter = $this->getMock(
'Cake\Routing\DispatcherFilter',
['beforeDispatch'],
[['when' => $matcher]]
);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch'])
->setConstructorArgs([['when' => $matcher]])
->getMock();
$filter->expects($this->never())
->method('beforeDispatch');
@@ -361,7 +361,9 @@ public function testDispatchActionReturnsResponse()
'pass' => []
]
]);
$response = $this->getMock('Cake\Network\Response', ['_sendHeader']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader'])
->getMock();
ob_start();
$this->dispatcher->dispatch($request, $response);
@@ -484,10 +486,9 @@ public function testDispatchBadName()
*/
public function testDispatcherFilter()
{
$filter = $this->getMock(
'Cake\Routing\DispatcherFilter',
['beforeDispatch', 'afterDispatch']
);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch', 'afterDispatch'])
->getMock();
$filter->expects($this->at(0))
->method('beforeDispatch');
@@ -504,7 +505,9 @@ public function testDispatcherFilter()
'pass' => []
]
]);
$response = $this->getMock('Cake\Network\Response', ['send']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['send'])
->getMock();
$this->dispatcher->dispatch($request, $response);
}
@@ -515,14 +518,15 @@ public function testDispatcherFilter()
*/
public function testBeforeDispatchAbortDispatch()
{
$response = $this->getMock('Cake\Network\Response', ['send']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['send'])
->getMock();
$response->expects($this->once())
->method('send');
$filter = $this->getMock(
'Cake\Routing\DispatcherFilter',
['beforeDispatch', 'afterDispatch']
);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch', 'afterDispatch'])
->getMock();
$filter->expects($this->once())
->method('beforeDispatch')
->will($this->returnValue($response));
@@ -543,14 +547,15 @@ public function testBeforeDispatchAbortDispatch()
*/
public function testAfterDispatchReplaceResponse()
{
$response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'send']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader', 'send'])
->getMock();
$response->expects($this->once())
->method('send');
$filter = $this->getMock(
'Cake\Routing\DispatcherFilter',
['beforeDispatch', 'afterDispatch']
);
$filter = $this->getMockBuilder('Cake\Routing\DispatcherFilter')
->setMethods(['beforeDispatch', 'afterDispatch'])
->getMock();
$filter->expects($this->once())
->method('afterDispatch')
@@ -13,7 +13,6 @@
*/
namespace Cake\Test\TestCase\Routing\Filter;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Event\Event;
use Cake\Network\Request;
@@ -62,7 +61,9 @@ public function testNotModified()
$time = filemtime(Plugin::path('TestTheme') . 'webroot/img/cake.power.gif');
$time = new \DateTime('@' . $time);
$response = $this->getMock('Cake\Network\Response', ['send', 'checkNotModified']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['send', 'checkNotModified'])
->getMock();
$request = new Request('test_theme/img/cake.power.gif');
$response->expects($this->once())->method('checkNotModified')
@@ -76,7 +77,9 @@ public function testNotModified()
$this->assertEquals(200, $response->statusCode());
$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
$response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'checkNotModified', 'send']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader', 'checkNotModified', 'send'])
->getMock();
$request = new Request('test_theme/img/cake.power.gif');
$response->expects($this->once())->method('checkNotModified')
@@ -99,7 +102,9 @@ public function test404OnDoubleSlash()
{
$filter = new AssetFilter();
$response = $this->getMock('Response', ['_sendHeader']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader'])
->getMock();
$request = new Request('//index.php');
$event = new Event('Dispatcher.beforeRequest', $this, compact('request', 'response'));
@@ -110,15 +115,17 @@ public function test404OnDoubleSlash()
/**
* Test that 404's are returned when .. is in the URL
*
* @return voi
* @return void
* @triggers Dispatcher.beforeRequest $this, compact('request', 'response')
* @triggers Dispatcher.beforeRequest $this, compact('request', 'response')
*/
public function test404OnDoubleDot()
{
$filter = new AssetFilter();
$response = $this->getMock('Response', ['_sendHeader']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader'])
->getMock();
$request = new Request('test_theme/../webroot/css/test_asset.css');
$event = new Event('Dispatcher.beforeRequest', $this, compact('request', 'response'));
@@ -232,7 +239,9 @@ public function testAsset($url, $file)
Plugin::load(['Company/TestPluginThree', 'TestPlugin', 'PluginJs']);
$filter = new AssetFilter();
$response = $this->getMock('Cake\Network\Response', ['_sendHeader']);
$response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['_sendHeader'])
->getMock();
$request = new Request($url);
$event = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
@@ -2770,11 +2770,10 @@ public function testUrlFullUrlReturnFromRoute()
{
$url = 'http://example.com/posts/view/1';
$route = $this->getMock(
'Cake\Routing\Route\Route',
['match'],
['/:controller/:action/*']
);
$route = $this->getMockBuilder('Cake\Routing\Route\Route')
->setMethods(['match'])
->setConstructorArgs(['/:controller/:action/*'])
->getMock();
$route->expects($this->any())
->method('match')
->will($this->returnValue($url));

0 comments on commit 893358f

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