Skip to content

Commit

Permalink
Merge pull request #4157 from dakota/3.0-fix-request-method-test-action
Browse files Browse the repository at this point in the history
Fix an issue with calling Request::method() in a test
  • Loading branch information
markstory committed Aug 4, 2014
2 parents becc9aa + 0131f10 commit 9048eda
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/TestSuite/ControllerTestCase.php
Expand Up @@ -254,10 +254,14 @@ protected function _testAction($url = '', $options = array()) {

$request = $this->getMock(
'Cake\Network\Request',
array('_readInput'),
array('_readInput', 'method'),
array($requestData)
);

$request->expects($this->any())
->method('method')
->will($this->returnValue($method));

if (is_string($options['data'])) {
$request->expects($this->any())
->method('_readInput')
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/TestSuite/ControllerTestCaseTest.php
Expand Up @@ -214,6 +214,24 @@ public function testTestAction() {
$this->assertEquals($expected, $results);
}

/**
* Tests testAction with call to request::method()
*
* @return void
*/
public function testTestActionWithRequestMethod() {
$Controller = $this->Case->generate('TestsApps');
$this->Case->testAction('/tests_apps/index', [
'method' => 'get'
]);
$this->assertSame('GET', $this->Case->controller->request->method());

$this->Case->testAction('/tests_apps/set_action', [
'method' => 'post'
]);
$this->assertSame('POST', $this->Case->controller->request->method());
}

/**
* Test testAction() with prefix routes.
*
Expand Down

0 comments on commit 9048eda

Please sign in to comment.