You are here

protected function RngTestTrait::createRegistration in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Tests/RngTestTrait.php \Drupal\rng\Tests\RngTestTrait::createRegistration()
  2. 8 src/Tests/RngTestTrait.php \Drupal\rng\Tests\RngTestTrait::createRegistration()

Create a registration and add an identity as a registrant.

Parameters

\Drupal\Core\Entity\EntityInterface $event: An event entity.

\Drupal\rng\Entity\RegistrationTypeInterface $registration_type: A registration type.

\Drupal\Core\Entity\EntityInterface[] $identities: An array of identities.

Return value

\Drupal\rng\Entity\RegistrationInterface A saved registration

2 calls to RngTestTrait::createRegistration()
RngRegistrationAccessTest::testRegisterSelfNoDuplicates in tests/src/Kernel/RngRegistrationAccessTest.php
Test register self no duplicates.
RngRegistrationAccessTest::testRegisterSelfWithDuplicates in tests/src/Kernel/RngRegistrationAccessTest.php
Test register self duplicates allowed.
1 method overrides RngTestTrait::createRegistration()
RngWebTestBase::createRegistration in src/Tests/RngWebTestBase.php
Creates and saves a registration entity.

File

src/Tests/RngTestTrait.php, line 89

Class

RngTestTrait

Namespace

Drupal\rng\Tests

Code

protected function createRegistration(EntityInterface $event, RegistrationTypeInterface $registration_type, array $identities) {
  $registration = Registration::create([
    'type' => $registration_type
      ->id(),
  ]);
  foreach ($identities as $identity) {
    $registration
      ->addIdentity($identity);
  }
  $registration
    ->setEvent($event)
    ->save();
  return $registration;
}