RngEventTypeAccessDefaultsTest.php in RNG - Events and Registrations 8.2
File
src/Tests/RngEventTypeAccessDefaultsTest.php
View source
<?php
namespace Drupal\rng\Tests;
use Drupal\Core\Url;
class RngEventTypeAccessDefaultsTest extends RngWebTestBase {
public static $modules = [
'entity_test',
];
protected function setUp() {
parent::setUp();
$admin = $this
->drupalCreateUser([
'administer event types',
]);
$this
->drupalLogin($admin);
}
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);
$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.'));
$this
->assertNoFieldChecked('edit-actions-operations-user-role-update');
$this
->assertFieldChecked('edit-actions-operations-user-role-delete');
}
}