/** * {@inheritdoc} */ public function makeNewSnapshots() { foreach ($this->objects as $id => $object) { $targetObject = ($object instanceof WrappedObject) ? $object->getWrappedObject() : $object; $this->snapshots[$id] = $this->snapshotMaker->makeSnapshotOf($targetObject); } }
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); }
/** * @param mixed $defaultValue * @param mixed $newValue * @param mixed $targetObject */ public function execute($defaultValue, $newValue, $targetObject) { $newValueSnapshot = $this->snapshotMaker->makeSnapshotOf($newValue); $this->propertyAccessor->setValue($this->snapshot, (string) $this->lazyProperty->getName(), $newValueSnapshot); }