Skip to content

Commit c9675d5

Browse files
committed
Add failing test demonstrating issue (dpi#143).
1 parent b9537f2 commit c9675d5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/src/Kernel/RngRegistrationEntityTest.php

+38
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\Tests\rng\Kernel;
44

55
use Drupal\Core\Entity\EntityStorageException;
6+
use Drupal\rng\Entity\EventType;
67
use Drupal\rng\Entity\Registrant;
78
use Drupal\simpletest\UserCreationTrait;
89
use Drupal\rng\Entity\Registration;
@@ -98,4 +99,41 @@ public function testAddIdentity() {
9899
$this->assertEquals($user1->id(), $registrant->getIdentity()->id(), 'Identity ID is same');
99100
}
100101

102+
/**
103+
* Test creating a registration for an event type that exceeds 32 characters.
104+
*/
105+
public function testLongEventTypeRegistration() {
106+
$event_type = $this->createEventTypeBase([
107+
'bundle' => 'event_type_over_32_characters',
108+
]);
109+
$event = $this->createEvent();
110+
$registration = Registration::create([
111+
'type' => $event_type->id(),
112+
]);
113+
$registration->setEvent($event->getEvent());
114+
$user1 = $this->drupalCreateUser();
115+
$registration
116+
->addIdentity($user1)
117+
->save();
118+
}
119+
120+
/**
121+
* Create a event type with only required info.
122+
*
123+
* @param array $values
124+
* Default values to use when creating the event type.
125+
*
126+
* @return \Drupal\rng\EventTypeInterface
127+
* An new event type entity.
128+
*/
129+
protected function createEventTypeBase($values = []) {
130+
$event_type = EventType::create($values + [
131+
'id' => $this->randomMachineName(33),
132+
'label' => $this->randomMachineName(),
133+
'entity_type' => 'entity_test',
134+
'bundle' => 'entity_test',
135+
]);
136+
return $event_type;
137+
}
138+
101139
}

0 commit comments

Comments
 (0)