Example #1
0
 public function testAddCollectionByKey()
 {
     $entity1 = new Entity(array('id' => 1));
     $collection1 = new Collection();
     $collection1->offsetSet($entity1->getId(), $entity1);
     $entity2 = new Entity(array('id' => 2));
     $collection2 = new Collection();
     $collection2->append($entity2);
     $expectedCollection = new Collection();
     $expectedCollection->offsetSet($entity1->getId(), $entity1);
     $expectedCollection->offsetSet($entity2->getId(), $entity2);
     $collection1->addCollection($collection2, 'id', true);
     $this->assertEquals($expectedCollection, $collection1);
 }