Skip to content

Commit

Permalink
Fix uniqueStrict for keyless collections
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro committed Oct 28, 2017
1 parent c30d094 commit 205c525
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,6 @@ public function transform(callable $callback)
*/
public function unique($key = null, $strict = false)
{
if (is_null($key)) {
return new static(array_unique($this->items, SORT_REGULAR));
}

$callback = $this->valueRetriever($key);

$exists = [];
Expand Down
6 changes: 6 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ public function testUnique()

$c = new Collection([[1, 2], [1, 2], [2, 3], [3, 4], [2, 3]]);
$this->assertEquals([[1, 2], [2, 3], [3, 4]], $c->unique()->values()->all());

$c = new Collection([10, '10']);
$this->assertEquals([10], $c->unique()->values()->all());
}

public function testUniqueWithCallback()
Expand Down Expand Up @@ -717,6 +720,9 @@ public function testUniqueStrict()
'name' => 'double zero',
],
], $c->uniqueStrict('id')->all());

$c = new Collection([10, '10']);
$this->assertEquals([10, '10'], $c->uniqueStrict()->values()->all());
}

public function testCollapse()
Expand Down

0 comments on commit 205c525

Please sign in to comment.