Skip to content

Commit

Permalink
Fix: Added params are lost if 'params' is revoked.
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Laviale committed Apr 12, 2014
1 parent 81f46d2 commit 85a21c9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ public function offsetGet($param)
public function offsetSet($param, $value)
{
$this->params[$param] = $value;
$this->request_params[$param] = $value;
}

/**
Expand Down
41 changes: 41 additions & 0 deletions tests/requestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 85a21c9

Please sign in to comment.