allowMethod() public method

Example: $this->request->allowMethod('post', 'delete'); or $this->request->allowMethod(array('post', 'delete')); If the request would be GET, response header "Allow: POST, DELETE" will be set and a 405 error will be returned.
public allowMethod ( string | array $methods ) : boolean
$methods string | array Allowed HTTP request methods.
return boolean true
 /**
  * Test allowMethod throwing exception
  *
  * @return void
  */
 public function testAllowMethodException()
 {
     $_SERVER['REQUEST_METHOD'] = 'PUT';
     $request = new CakeRequest('/posts/edit/1');
     try {
         $request->allowMethod('POST', 'DELETE');
         $this->fail('An expected exception has not been raised.');
     } catch (MethodNotAllowedException $e) {
         $this->assertEquals(array('Allow' => 'POST, DELETE'), $e->responseHeader());
     }
     $this->setExpectedException('MethodNotAllowedException');
     $request->allowMethod('POST');
 }