diff --git a/tests/src/Kernel/RngRegistrationEntityTest.php b/tests/src/Kernel/RngRegistrationEntityTest.php index 1af8d67..a62e25c 100644 --- a/tests/src/Kernel/RngRegistrationEntityTest.php +++ b/tests/src/Kernel/RngRegistrationEntityTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\rng\Kernel; use Drupal\Core\Entity\EntityStorageException; +use Drupal\rng\Entity\EventType; use Drupal\rng\Entity\Registrant; use Drupal\simpletest\UserCreationTrait; use Drupal\rng\Entity\Registration; @@ -98,4 +99,41 @@ public function testAddIdentity() { $this->assertEquals($user1->id(), $registrant->getIdentity()->id(), 'Identity ID is same'); } + /** + * Test creating a registration for an event type that exceeds 32 characters. + */ + public function testLongEventTypeRegistration() { + $event_type = $this->createEventTypeBase([ + 'bundle' => 'event_type_over_32_characters', + ]); + $event = $this->createEvent(); + $registration = Registration::create([ + 'type' => $event_type->id(), + ]); + $registration->setEvent($event->getEvent()); + $user1 = $this->drupalCreateUser(); + $registration + ->addIdentity($user1) + ->save(); + } + + /** + * Create a event type with only required info. + * + * @param array $values + * Default values to use when creating the event type. + * + * @return \Drupal\rng\EventTypeInterface + * An new event type entity. + */ + protected function createEventTypeBase($values = []) { + $event_type = EventType::create($values + [ + 'id' => $this->randomMachineName(33), + 'label' => $this->randomMachineName(), + 'entity_type' => 'entity_test', + 'bundle' => 'entity_test', + ]); + return $event_type; + } + }