You are here

public function ScheduledTransitionSettingsFormTest::testMirrorOperations 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::testMirrorOperations()

Tests mirror operations settings.

File

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

Class

ScheduledTransitionSettingsFormTest
Tests settings form.

Namespace

Drupal\Tests\scheduled_transitions\Functional

Code

public function testMirrorOperations() : void {

  // Set operation values to nothing.
  \Drupal::configFactory()
    ->getEditable('scheduled_transitions.settings')
    ->clear('mirror_operations.view scheduled transition')
    ->clear('mirror_operations.add scheduled transition')
    ->save(TRUE);
  $currentUser = $this
    ->drupalCreateUser([
    'administer scheduled transitions',
  ]);
  $this
    ->drupalLogin($currentUser);
  $url = Url::fromRoute('scheduled_transitions.settings');
  $this
    ->drupalGet($url);
  $this
    ->assertSession()
    ->fieldValueEquals('mirror_operation_view', '');
  $this
    ->assertSession()
    ->fieldValueEquals('mirror_operation_add', '');
  $edit = [
    'mirror_operation_view' => 'update',
    'mirror_operation_add' => 'update',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->fieldValueEquals('mirror_operation_view', 'update');
  $this
    ->assertSession()
    ->fieldValueEquals('mirror_operation_add', 'update');
}