public function testAll()
 {
     $this->model = new ParticipateModel();
     $state = $this->model->insertEventParticipation(1, 1);
     $this->assertEquals(true, $state);
     $state = $this->model->getEventParticipation(1);
     $this->assertNotEmpty($state);
     $state = $this->model->deleteEventParticipation(1, 1);
     $this->assertEquals(true, $state);
 }
 public function unparticipate()
 {
     if (!Authentication::getInstance()->isAuthenticated()) {
         throw new NotAuthenticatedException();
     }
     $id = (int) $this->getParams()[0];
     $event = $this->eventModel->get($id);
     if (empty($event)) {
         throw new EventNotFoundException($id);
     }
     $participate = $this->eventModel->getParticipateUser($id, Authentication::getInstance()->getUserId());
     if (empty($participate)) {
         throw new NotParticipateEventException($id, Authentication::getInstance()->getUserId());
     }
     $this->participateModel->deleteEventParticipation($id, Authentication::getInstance()->getUserId());
     $this->getView()->redirect('/event/show/' . $id);
 }