function RngEventTypeAccessDefaultsTest::testAccessDefaults in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Tests/RngEventTypeAccessDefaultsTest.php \Drupal\rng\Tests\RngEventTypeAccessDefaultsTest::testAccessDefaults()
- 3.x src/Tests/RngEventTypeAccessDefaultsTest.php \Drupal\rng\Tests\RngEventTypeAccessDefaultsTest::testAccessDefaults()
Test access defaults.
File
- src/
Tests/ RngEventTypeAccessDefaultsTest.php, line 34
Class
- RngEventTypeAccessDefaultsTest
- Tests event type access defaults.
Namespace
Drupal\rng\TestsCode
function testAccessDefaults() {
$edit = [
'bundle' => 'entity_test.entity_test',
'registrants[registrant_type]' => 'registrant',
];
$this
->drupalPostForm(Url::fromRoute('entity.event_type.add'), $edit, t('Save'));
$defaults_route = Url::fromRoute('entity.event_type.access_defaults', [
'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');
}