mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding CakeRequest::method() to find the name of the HTTP method name used for the request. Test case added.
This commit is contained in:
parent
4a8e44b419
commit
0ec0962932
2 changed files with 21 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue