You are here

public function ScheduledTransitionSettingsFormTest::testNoPermissionsMessage in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/ScheduledTransitionSettingsFormTest.php \Drupal\Tests\scheduled_transitions\Functional\ScheduledTransitionSettingsFormTest::testNoPermissionsMessage()

Tests permission message on form.

File

tests/src/Functional/ScheduledTransitionSettingsFormTest.php, line 121

Class

ScheduledTransitionSettingsFormTest
Tests settings form.

Namespace

Drupal\Tests\scheduled_transitions\Functional

Code

public function testNoPermissionsMessage() : void {
  $workflow = $this
    ->createEditorialWorkflow();
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('st_entity_test', 'st_entity_test');
  $workflow
    ->save();
  $this
    ->enabledBundles([
    [
      'st_entity_test',
      'st_entity_test',
    ],
  ]);
  $message = 'Notice: no roles are currently granted permissions for this type.';
  $currentUser = $this
    ->drupalCreateUser([
    'administer scheduled transitions',
  ]);
  $this
    ->drupalLogin($currentUser);
  $url = Url::fromRoute('scheduled_transitions.settings');
  $this
    ->drupalGet($url);
  $this
    ->assertSession()
    ->pageTextContains($message);
  $testRole = Role::create([
    'id' => 'test_role',
  ]);
  $testRole
    ->grantPermission(Permissions::viewScheduledTransitionsPermission('st_entity_test', 'st_entity_test'));
  $testRole
    ->save();
  $this
    ->drupalGet($url);
  $this
    ->assertSession()
    ->pageTextNotContains($message);
}