Skip to content

Commit

Permalink
Fixes laravel#5235 bug causing incorrect renaming of numeric keys
Browse files Browse the repository at this point in the history
(and adds test for reproducing and verifying fix)
  • Loading branch information
andyfleming committed Jul 26, 2014
1 parent e6849dc commit 9e08925
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Request.php
Expand Up @@ -214,7 +214,7 @@ protected function isEmptyString($key)
*/
public function all()
{
return array_merge_recursive($this->input(), $this->files->all());
return array_replace_recursive($this->input(), $this->files->all());
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/Http/HttpRequestTest.php
Expand Up @@ -327,6 +327,26 @@ public function testAllInputReturnsNestedInputAndFiles()
$request = Request::create('/?boom=breeze', 'GET', array('foo' => array('bar' => 'baz')), array(), array('foo' => array('photo' => $file)));
$this->assertEquals(array('foo' => array('bar' => 'baz', 'photo' => $file), 'boom' => 'breeze'), $request->all());
}


public function testAllInputReturnsInputAfterReplace()
{
$request = Request::create('/?boom=breeze', 'GET', array('foo' => array('bar' => 'baz')));
$request->replace(array('foo' => array('bar' => 'baz'), 'boom' => 'breeze'));
$this->assertEquals(array('foo' => array('bar' => 'baz'), 'boom' => 'breeze'), $request->all());
}


public function testAllInputWithNumericKeysReturnsInputAfterReplace()
{
$request1 = Request::create('/', 'POST', array(0 => 'A', 1 => 'B', 2 => 'C'));
$request1->replace(array(0 => 'A', 1 => 'B', 2 => 'C'));
$this->assertEquals(array(0 => 'A', 1 => 'B', 2 => 'C'), $request1->all());

$request2 = Request::create('/', 'POST', array(1 => 'A', 2 => 'B', 3 => 'C'));
$request2->replace(array(1 => 'A', 2 => 'B', 3 => 'C'));
$this->assertEquals(array(1 => 'A', 2 => 'B', 3 => 'C'), $request2->all());
}


public function testOldMethodCallsSession()
Expand Down

0 comments on commit 9e08925

Please sign in to comment.