/** * Test allowMethod throwing exception * * @return void */ public function testAllowMethodException() { $request = new Request(['url' => '/posts/edit/1', 'environment' => ['REQUEST_METHOD' => 'PUT']]); try { $request->allowMethod(['POST', 'DELETE']); $this->fail('An expected exception has not been raised.'); } catch (Exception\MethodNotAllowedException $e) { $this->assertEquals(['Allow' => 'POST, DELETE'], $e->responseHeader()); } $this->setExpectedException('Cake\\Network\\Exception\\MethodNotAllowedException'); $request->allowMethod('POST'); }