Skip to content

Commit

Permalink
Merge pull request #199 from koriym/override
Browse files Browse the repository at this point in the history
fix Override method POST value
  • Loading branch information
koriym committed Jun 3, 2015
2 parents 9cc47b3 + b13f80c commit ffb0952
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ filter:
paths: ["src/*"]
tools:
external_code_coverage: true
php_code_coverage: true
php_code_coverage:
timeout: 1200
php_sim: true
php_mess_detector: true
php_pdepend: true
php_analyzer: true
Expand Down
3 changes: 2 additions & 1 deletion src/Provide/Router/HttpMethodParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function get(array $server, array $get, array $post)
// must be a POST to do an override
$override = $this->getOverRideMethod($server, $post);
if ($override) {
return [$override, $this->getParams($method, $get, $post, $server)];
// must be a POST to do an override
return [$override, $post];
}
if ($method === 'post') {
return ['post', $post];
Expand Down
19 changes: 13 additions & 6 deletions tests/Provide/Router/HttpMethodParamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,32 @@ public function testDelete()
public function testOverridePut()
{
$server = ['REQUEST_METHOD' => 'POST', HttpMethodParams::CONTENT_TYPE => HttpMethodParams::FORM_URL_ENCODE];
$post = ['_method' => 'PUT'];
list($method, ) = (new HttpMethodParams)->get($server, [], $post);
$post = ['_method' => 'PUT', 'id' => 1];
list($method, $param) = (new HttpMethodParams)->get($server, [], $post);
$this->assertSame('put', $method);
$expected = ['id' => 1];
$this->assertSame($expected, $param);

}

public function testOverridePatch()
{
$server = ['REQUEST_METHOD' => 'POST', HttpMethodParams::CONTENT_TYPE => HttpMethodParams::FORM_URL_ENCODE];
$post = ['_method' => 'PATCH'];
list($method, ) = (new HttpMethodParams)->get($server, [], $post);
$post = ['_method' => 'PATCH', 'id' => 1];
list($method, $param) = (new HttpMethodParams)->get($server, [], $post);
$this->assertSame('patch', $method);
$expected = ['id' => 1];
$this->assertSame($expected, $param);
}

public function testOverrideDelete()
{
$server = ['REQUEST_METHOD' => 'POST', HttpMethodParams::CONTENT_TYPE => HttpMethodParams::FORM_URL_ENCODE];
$post = ['_method' => 'DELETE'];
list($method, ) = (new HttpMethodParams)->get($server, [], $post);
$post = ['_method' => 'DELETE', 'id' => 1];
list($method, $param) = (new HttpMethodParams)->get($server, [], $post);
$this->assertSame('delete', $method);
$expected = ['id' => 1];
$this->assertSame($expected, $param);
}

public function testOverrideHeaderPut()
Expand Down

0 comments on commit ffb0952

Please sign in to comment.