/**
  * @test
  */
 public function synchronizeHandlesHigherSourceIdInQueueComparisonByCreatingObject()
 {
     $idOfSourceObject = 2;
     $sourceObject = new SourceObjectDummy();
     $this->setUpSourceToReturn(new \ArrayIterator(array($sourceObject)));
     $idOfDestinationObject = 1;
     $destinationObject = new DestinationObjectDummy();
     $this->setUpDestinationToReturn(new \ArrayIterator(array($destinationObject)));
     $this->mapper->expects($this->any(0))->method('idOf')->will($this->returnValue($idOfSourceObject));
     $this->destination->expects($this->any())->method('idOf')->will($this->returnValue($idOfDestinationObject));
     $this->mapper->expects($this->once())->method('map')->will($this->returnValue(MapResult::changed($destinationObject)));
     $this->destination->expects($this->once())->method('delete')->with($destinationObject);
     $this->synchronizer->synchronize($this->className, false);
 }
 /**
  * @param mixed $sourceObject
  * @param mixed $destinationObject
  */
 private function update($sourceObject, $destinationObject)
 {
     if ($this->destination instanceof UpdateableObjectProviderInterface) {
         $destinationObject = $this->destination->prepareUpdate($destinationObject);
     }
     $mapResult = $this->mapper->map($sourceObject, $destinationObject);
     if ($mapResult->getObjectHasChanged() === true) {
         $this->destination->updated($mapResult->getObject());
         $this->logger->info('Updated object with id {id}.', array('id' => $this->mapper->idOf($sourceObject)));
     } else {
         $this->logger->info('Kept object with id {id}.', array('id' => $this->mapper->idOf($sourceObject)));
     }
     $this->destinationQueue->next();
     $this->sourceQueue->next();
 }