You are here

public function RngEventAccessWebTest::testEventAccessSiteDefaults in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/RngEventAccessWebTest.php \Drupal\Tests\rng\Functional\RngEventAccessWebTest::testEventAccessSiteDefaults()
  2. 3.x tests/src/Functional/RngEventAccessWebTest.php \Drupal\Tests\rng\Functional\RngEventAccessWebTest::testEventAccessSiteDefaults()

Test event access page when using site defaults.

File

tests/src/Functional/RngEventAccessWebTest.php, line 46

Class

RngEventAccessWebTest
Tests manage event access page.

Namespace

Drupal\Tests\rng\Functional

Code

public function testEventAccessSiteDefaults() {
  $user1 = $this
    ->drupalCreateUser([
    'view test entity',
    'administer entity_test content',
  ]);
  $this
    ->drupalLogin($user1);
  $event_meta = $this
    ->createEvent([
    'user_id' => $user1
      ->id(),
  ]);
  $this
    ->drupalGet(Url::fromRoute('rng.event.entity_test.access', [
    'entity_test' => $event_meta
      ->getEvent()
      ->id(),
  ]));

  // Reset access rules button.
  $reset_link = Url::fromRoute('rng.event.entity_test.access.reset', [
    'entity_test' => $event_meta
      ->getEvent()
      ->id(),
  ]);
  $this
    ->assertSession()
    ->linkExists(t('Customize access rules'));
  $this
    ->assertSession()
    ->linkByHrefExists($reset_link
    ->toString());

  // Check if one of the checkboxes is disabled.
  $field_name = 'table[6][operation_create][enabled]';
  $this
    ->assertSession()
    ->fieldExists($field_name);
  $input = $this
    ->xpath('//input[@name="' . $field_name . '" and @disabled="disabled"]');
  $this
    ->assertTrue(count($input) === 1, 'The create checkbox is disabled.');
}