/** * Test does not override method if no method ovveride parameter */ public function testDoesNotOverrideMethodAsPostWithoutParameter() { $env = array('REQUEST_METHOD' => 'POST', 'REMOTE_ADDR' => '127.0.0.1', 'SCRIPT_NAME' => '/foo/index.php', 'PATH_INFO' => '/bar', 'QUERY_STRING' => 'foo=bar', 'SERVER_NAME' => 'slim', 'SERVER_PORT' => 80, 'slim.url_scheme' => 'http', 'slim.input' => '', 'slim.errors' => fopen('php://stderr', 'w')); $app = new CustomAppMethod(); $mw = new Slim_Middleware_MethodOverride($app); $result = $mw->call($env); $this->assertEquals('POST', $result); $this->assertFalse(isset($env['slim.method_override.original_method'])); }
/** * Test overrides method with X-Http-Method-Override header */ public function testOverrideMethodAsHeader() { Slim_Environment::mock(array('REQUEST_METHOD' => 'POST', 'CONTENT_TYPE' => 'application/json', 'CONENT_LENGTH' => 0, 'slim.input' => '', 'X_HTTP_METHOD_OVERRIDE' => 'DELETE')); $app = new CustomAppMethod(); $mw = new Slim_Middleware_MethodOverride(); $mw->setApplication($app); $mw->setNextMiddleware($app); $mw->call(); $env =& $app->environment(); $this->assertEquals('DELETE', $env['REQUEST_METHOD']); $this->assertTrue(isset($env['slim.method_override.original_method'])); $this->assertEquals('POST', $env['slim.method_override.original_method']); }