/** * @test */ public function synchronizeDoesNotCallUpdatedForObjectsThatRemainedTheSame() { $sameIdForSourceAndDestinationObject = 1; $newerVersionOfSourceObject = new ObjectDummy(); $this->setUpSourceToReturn(new \ArrayIterator(array($newerVersionOfSourceObject))); $olderVersionOfDestinationObject = new ObjectDummy(); $this->setUpDestinationToReturn(new \ArrayIterator(array($olderVersionOfDestinationObject))); $this->source->expects($this->any())->method('idOf')->will($this->returnValue($sameIdForSourceAndDestinationObject)); $this->destination->expects($this->any())->method('idOf')->will($this->returnValue($sameIdForSourceAndDestinationObject)); $this->destination->expects($this->once())->method('prepareUpdate')->with($olderVersionOfDestinationObject); $this->destination->expects($this->never())->method('updated'); // afterObjectProcessed() called for every object $this->destination->expects($this->once())->method('afterObjectProcessed'); $this->destination->expects($this->once())->method('commit'); $this->synchronizer->synchronize($this->type, function () { return Result::unchanged(); }); }
/** * @test */ public function indexHandlesEmptySourceObjectsSet() { $emptySet = new \ArrayIterator(); $this->setUpSourceToReturn($emptySet); $this->setExpectedException(null); $this->indexer->index($this->type, function () { return Result::unchanged(); }); }