Пример #1
0
    /**
     * {@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);
            }
        }
    }
Пример #2
0
 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);
 }