protected function applyTaskDescriptionWasChanged(TaskDescriptionWasChanged $event)
 {
     $task = $this->getTask($event->getTaskId());
     $task->changeDescription($event->getNewDescription());
 }
 /** @test */
 function it_can_cancel_pending_changes()
 {
     $taskListId = TaskListId::generate();
     $domainEvents = new DomainEvents();
     $pendingChanges = new DomainEvents();
     $cancelledChange = new TaskDescriptionWasChanged($taskListId, TaskId::generate(), 'Learn more DDD!', 'Implement Event Sourcing');
     $pendingChange = new TaskDescriptionWasChanged($taskListId, TaskId::generate(), 'Draw Boxes', 'Draw EVEN more boxes');
     $domainEvents->push(new TaskWasAdded($taskListId, $cancelledChange->getTaskId(), 'Learn more DDD!'));
     $domainEvents->push(new TaskWasAdded($taskListId, $pendingChange->getTaskId(), 'Draw Boxes'));
     $pendingChanges->push($cancelledChange);
     $pendingChanges->push($pendingChange);
     $taskList = TaskList::reconstituteFrom($taskListId, $domainEvents, $pendingChanges);
     $taskList->cancelPendingChange($cancelledChange->getKey());
     $pendingChanges = $taskList->getPendingChanges();
     $this->assertCount(1, $pendingChanges);
     $this->assertTrue($pendingChanges->contains($pendingChange));
 }