You are here

public function RngEventTypeAccessDefaultsTest::testAccessDefaults in RNG - Events and Registrations 3.x

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

Test access defaults.

File

src/Tests/RngEventTypeAccessDefaultsTest.php, line 29

Class

RngEventTypeAccessDefaultsTest
Tests event type access defaults.

Namespace

Drupal\rng\Tests

Code

public function testAccessDefaults() {
  $edit = [
    'bundle' => 'entity_test.entity_test',
    'registrants[registrant_type]' => 'registrant',
  ];
  $this
    ->drupalPostForm(Url::fromRoute('entity.rng_event_type.add'), $edit, t('Save'));
  $defaults_route = Url::fromRoute('entity.rng_event_type.access_defaults', [
    'rng_event_type' => 'entity_test.entity_test',
  ]);
  $this
    ->drupalGet($defaults_route);

  // Ensure checkboxes have default values.
  $this
    ->assertNoFieldById('edit-actions-operations-event-manager-create');
  $this
    ->assertFieldChecked('edit-actions-operations-event-manager-view');
  $this
    ->assertFieldChecked('edit-actions-operations-event-manager-update');
  $this
    ->assertFieldChecked('edit-actions-operations-event-manager-delete');
  $this
    ->assertNoFieldById('edit-actions-operations-registrant-create');
  $this
    ->assertFieldChecked('edit-actions-operations-registrant-view');
  $this
    ->assertFieldChecked('edit-actions-operations-registrant-update');
  $this
    ->assertNoFieldChecked('edit-actions-operations-registrant-delete');
  $this
    ->assertFieldChecked('edit-actions-operations-user-role-create');
  $this
    ->assertNoFieldChecked('edit-actions-operations-user-role-view');
  $this
    ->assertNoFieldChecked('edit-actions-operations-user-role-update');
  $this
    ->assertNoFieldChecked('edit-actions-operations-user-role-delete');
  $edit = [
    'actions[operations][user_role][delete]' => TRUE,
  ];
  $this
    ->drupalPostForm($defaults_route, $edit, t('Save'));
  $this
    ->assertRaw(t('Event type access defaults saved.'));

  // Update field still unchecked.
  $this
    ->assertNoFieldChecked('edit-actions-operations-user-role-update');

  // Delete field is now checked.
  $this
    ->assertFieldChecked('edit-actions-operations-user-role-delete');
}