Adding CakeRequest::method() to find the name of the HTTP method name used for the request. Test case added.

This commit is contained in:
mark_story 2010-08-22 00:15:13 -04:00
parent 4a8e44b419
commit 0ec0962932
2 changed files with 21 additions and 0 deletions

View file

@ -552,6 +552,15 @@ class CakeRequest implements ArrayAccess {
return false;
}
/**
* Get the HTTP method used for this request.
*
* @return string The name of the HTTP method used.
*/
public function method() {
return env('REQUEST_METHOD');
}
/**
* Find out which content types the client accepts or check if they accept a
* particular type of content.

View file

@ -500,6 +500,18 @@ class CakeRequestTestCase extends CakeTestCase {
$this->assertFalse($request->is('delete'));
}
/**
* test the method() method.
*
* @return void
*/
function testMethod() {
$_SERVER['REQUEST_METHOD'] = 'delete';
$request = new CakeRequest('some/path');
$this->assertEquals('delete', $request->method());
}
/**
* test ajax, flash and friends
*