public function Updated(Event $event) { $attributes = array_map(function ($value) { return $value instanceof Emitter ? $value->getId() : $value; }, $event->getAttributes()['changeSet']); $this->ensureSchema($this->getTableName($event->getEmitterClass()), $attributes); $this->connection->update($this->getTableName($event->getEmitterClass()), $attributes, ['id' => $event->getEmitterId()]); }
function it_reconstructs_current_state_of_an_object_by_replaying_its_past_events(Replayable $emitter, Event $isBorn, Event $hasLived, Event $isDead, \ArrayIterator $events) { $isBorn->getName()->willReturn('born'); $isBorn->getAttributes()->willReturn(['id' => 10]); $hasLived->getName()->willReturn('to be'); $hasLived->getAttributes()->willReturn([]); $isDead->getName()->willReturn('wild'); $isDead->getAttributes()->willReturn([]); $events->iterates([$isBorn, $hasLived, $isDead]); $emitter = $this->replay($events, 'spec\\Knp\\Event\\Player\\Replayable'); $emitter->getId()->shouldEqual(10); }