/** * {@inheritdoc} */ public function reset() { $this->removed = []; foreach ($this->snapshots as $id => $objectSnapshot) { if ($this->objects[$id] instanceof WrappedObject) { $this->propertyCloner->cloneProperties($this->objects[$id]->getWrappedObject(), $objectSnapshot); } else { $this->propertyCloner->cloneProperties($this->objects[$id], $objectSnapshot); } } }
function it_resets_objects_to_states_from_snapshots(SnapshotMaker $cloner, PropertyCloner $recoveryPoint) { $object = new EntityFake(1, "Norbert", "Orzechowicz"); $objectSnapshot = new EntityFake(1, "Norbert", "Orzechowicz"); $cloner->makeSnapshotOf($object)->willReturn($objectSnapshot); $this->register($object); $object->changeFirstName("Dawid"); $object->changeLastName("Sajdak"); $objectToRemove = new EntityFake(2); $this->remove($objectToRemove); $this->reset(); $recoveryPoint->cloneProperties($object, $objectSnapshot)->shouldHaveBeenCalled(); $this->isRemoved($objectToRemove)->shouldReturn(false); }