You are here

public function RngViewsTest::testRegisterLink in RNG - Events and Registrations 8.2

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

Test register link field.

File

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

Class

RngViewsTest
Tests RNG field plugins.

Namespace

Drupal\Tests\rng\Kernel\Views

Code

public function testRegisterLink() {
  $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',
    ],
  ]);
  $this->view
    ->save();
  $this->view
    ->preview();
  $expected = Link::createFromRoute(t('Register'), 'rng.event.entity_test.register.type_list', [
    'entity_test' => $event
      ->id(),
  ])
    ->toString();
  $actual = $this->view->style_plugin
    ->getField(0, 'rng_event_register');
  $this
    ->assertEqual($actual, $expected);
}