diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 01984338e18a..50eb9d85dcf1 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -123,17 +123,13 @@ public function many(array $keys) */ public function getMultiple($keys, $default = null) { - if (is_null($default)) { - return $this->many($keys); - } + $defaults = []; foreach ($keys as $key) { - if (! isset($default[$key])) { - $default[$key] = null; - } + $defaults[$key] = $default; } - return $this->many($default); + return $this->many($defaults); } /** diff --git a/tests/Cache/CacheRepositoryTest.php b/tests/Cache/CacheRepositoryTest.php index 53a65e320855..7c463d9c8b38 100755 --- a/tests/Cache/CacheRepositoryTest.php +++ b/tests/Cache/CacheRepositoryTest.php @@ -214,11 +214,11 @@ public function testClearingWholeCache() public function testGettingMultipleValuesFromCache() { $keys = ['key1', 'key2', 'key3']; - $default = ['key2' => 5]; + $default = 5; $repo = $this->getRepository(); - $repo->getStore()->shouldReceive('many')->once()->with(['key2', 'key1', 'key3'])->andReturn(['key1' => 1, 'key2' => null, 'key3' => null]); - $this->assertEquals(['key1' => 1, 'key2' => 5, 'key3' => null], $repo->getMultiple($keys, $default)); + $repo->getStore()->shouldReceive('many')->once()->with(['key1', 'key2', 'key3'])->andReturn(['key1' => 1, 'key2' => null, 'key3' => null]); + $this->assertEquals(['key1' => 1, 'key2' => 5, 'key3' => 5], $repo->getMultiple($keys, $default)); } public function testRemovingMultipleKeys()