You are here

public function RngViewsTest::testRegisterLinkWithRegistrationType in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Views/RngViewsTest.php \Drupal\Tests\rng\Kernel\Views\RngViewsTest::testRegisterLinkWithRegistrationType()
  2. 3.x tests/src/Kernel/Views/RngViewsTest.php \Drupal\Tests\rng\Kernel\Views\RngViewsTest::testRegisterLinkWithRegistrationType()

Test register link field with a registration type.

File

tests/src/Kernel/Views/RngViewsTest.php, line 113

Class

RngViewsTest
Tests RNG field plugins.

Namespace

Drupal\Tests\rng\Kernel\Views

Code

public function testRegisterLinkWithRegistrationType() {
  $event = $this
    ->createEvent()
    ->getEvent();
  $user1 = $this
    ->drupalCreateUser([
    'rng register self',
  ]);
  $this
    ->setCurrentUser($user1);
  $this
    ->createUserRoleRules([], [
    'create' => TRUE,
  ]);
  $this->view->displayHandlers
    ->get('default')
    ->overrideOption('fields', [
    'rng_event_register' => [
      'table' => 'entity_test',
      'field' => 'rng_event_register',
      'id' => 'rng_event_register',
      'plugin_id' => 'rng_event_register',
      'entity_type' => 'entity_test',
      'registration_type' => $this->registrationType
        ->id(),
    ],
  ]);
  $this->view
    ->save();
  $this->view
    ->preview();
  $expected = Link::createFromRoute(t('Register'), 'rng.event.entity_test.register', [
    'entity_test' => $event
      ->id(),
    'registration_type' => $this->registrationType
      ->id(),
  ])
    ->toString();
  $actual = $this->view->style_plugin
    ->getField(0, 'rng_event_register');
  $this
    ->assertEquals($expected, $actual);
}