public function handle(Command $command) { $description = $command->description(); $task = Task::create($description); // do something to persist the task $stream = $task->getRecordedEvents(); $task->clearRecordedEvents(); foreach ($stream as $message) { $this->dispatcher->dispatch($message); } }
/** * @expectedException Novuso\Common\Domain\EventStore\Exception\StreamNotFoundException */ public function test_that_load_stream_throws_exception_when_id_does_not_have_a_stream() { $task = Task::create('First task description'); $stream = $task->getRecordedEvents(); $this->store->appendStream($stream); $task->clearRecordedEvents(); $other = Task::create('Another task'); $this->store->loadStream($other->id(), Type::create($other)); }
/** * @expectedException Novuso\System\Exception\OperationException */ public function test_initialize_committed_version_throws_exception_with_invalid_call() { $task = Task::create('Go to the store'); $task->initializeVersion(0); }