public function newRegistration($id) { try { $report = new Report($id); if (!$report->isRegistrable()) { throw new fValidationException('This contest is not registrable.'); } $registration = new Registration(); $registration->setUsername(fAuthorization::getUserToken()); $registration->setReportId($report->getId()); $registration->store(); BoardCacheInvalidator::invalidateByReport($report); fMessaging::create('success', 'Registered successfully.'); } catch (fExpectedException $e) { fMessaging::create('warning', $e->getMessage()); } catch (fUnexpectedException $e) { fMessaging::create('error', $e->getMessage()); } fURL::redirect(Util::getReferer()); }
public function testDeleteForceCascadeOneToMany() { $event = new Event(); $event->setTitle('Delete Restrict Event'); $event->setStartDate(new fDate()); $event->store(); $registration = new Registration(); $registration->setEventId($event->getEventId()); $registration->setName('Will'); $registration->store(); $event->delete(TRUE); $this->assertEquals(FALSE, $event->exists()); }