/** * Test registrations. */ function testRegistrationAPI() { $this->assertIdentical(0, count(Registration::loadMultiple()), 'There are no registrations'); // Test registration creation. $registration[0] = $this->createRegistration($this->event, $this->registration_type->id()); $this->assertIdentical(1, count(Registration::loadMultiple()), 'There is one registration'); }
/** * Creates and saves a registration entity. * * @param \Drupal\Core\Entity\ContentEntityInterface $event * An event entity. * @param string $registration_type_id * A registration type ID. * * @return \Drupal\rng\Entity\Registration * A saved registration entity. */ function createRegistration(ContentEntityInterface $event, $registration_type_id) { $registration = Registration::create(['type' => $registration_type_id])->setEvent($event); $registration->save(); return $registration; }
/** * Test registration type deletion. */ function testRegistrationTypeAPIDelete() { // Associate event with registration type. $this->event->{EventManagerInterface::FIELD_REGISTRATION_TYPE}->appendItem(['target_id' => $this->registration_type->id()]); $this->event->save(); $this->assertEqual(1, $this->countEventRegistrationTypeReferences($this->event->getEntityTypeId(), $this->registration_type->id()), 'One reference exists to this registration type'); $registration[0] = $this->createRegistration($this->event, $this->registration_type->id()); $this->registration_type->delete(); $this->assertIdentical(0, count(Registration::loadMultiple()), 'Registrations no longer exist'); $this->assertEqual(0, $this->countEventRegistrationTypeReferences($this->event->getEntityTypeId(), $this->registration_type->id()), 'No references from event entities to this registration type'); }
/** * Provides a registration form. * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The matched route. * * @param string $event * The parameter to find the event entity. * * @param \Drupal\rng\RegistrationTypeInterface $registration_type * The type of registration. * * @return array A registration form. */ public function RegistrationAdd(RouteMatchInterface $route_match, $event, RegistrationTypeInterface $registration_type) { $event_entity = $route_match->getParameter($event); $registration = Registration::create(['type' => $registration_type->id()]); $registration->setEvent($event_entity); return $this->entityFormBuilder()->getForm($registration, 'add', array($event_entity)); }