diff --git a/lib/request.php b/lib/request.php index de0223e..6903ef0 100755 --- a/lib/request.php +++ b/lib/request.php @@ -421,6 +421,7 @@ public function offsetGet($param) public function offsetSet($param, $value) { $this->params[$param] = $value; + $this->request_params[$param] = $value; } /** diff --git a/tests/requestTest.php b/tests/requestTest.php index 202d600..20d5d26 100755 --- a/tests/requestTest.php +++ b/tests/requestTest.php @@ -324,4 +324,45 @@ public function test_path_when_uri_is_missing_query_string() $this->assertEquals('/api/users/login', $r->uri); $this->assertEquals('/api/users/login', $r->path); } + + public function test_params() + { + $r = Request::from([ + + 'path_params' => [ + + 'p1' => 1, + 'p2' => 2 + + ], + + 'request_params' => [ + + 'p1' => 10, + 'p2' => 20, + 'p3' => 3 + + ], + + 'query_params' => [ + + 'p1' => 100, + 'p2' => 200, + 'p3' => 300, + 'p4' => 4 + + ] + + ]); + + $this->assertSame([ 'p1' => 1, 'p2' => 2, 'p3' => 3, 'p4' => 4 ], $r->params); + + $r['p5'] = 5; + + $expected = [ 'p1' => 1, 'p2' => 2, 'p3' => 3, 'p4' => 4, 'p5' => 5 ]; + $this->assertSame($expected, $r->params); + unset($r->params); + $expected = [ 'p1' => 1, 'p2' => 2, 'p3' => 3, 'p4' => 4, 'p5' => 5 ]; + $this->assertEquals($expected, $r->params); + } } \ No newline at end of file