unique() public method

Return only unique items from the collection.
public unique ( ) : Collection
return FOF30\Utils\Collection
Example #1
0
 /**
  * @group           DataModel
  * @group           CollectionModelUnique
  * @covers          FOF30\Model\DataModel\Collection::unique
  */
 public function testUnique()
 {
     $items = $this->buildCollection();
     // Let's duplicate an item
     $items["1"] = $items[1];
     $collection = new Collection($items);
     $newCollection = $collection->unique();
     $this->assertInstanceOf('\\FOF30\\Model\\DataModel\\Collection', $newCollection, 'Collection::unique should return an instance of Collection');
     $this->assertCount(3, $newCollection);
     $this->assertEquals(array(1 => 1, 2 => 2, 3 => 3), $collection->modelKeys());
 }