You are here

public function ModerationStateStatesTest::testStateAdministration in Workbench Moderation 8.2

Tests administration of moderation state entity.

File

src/Tests/ModerationStateStatesTest.php, line 40

Class

ModerationStateStatesTest
Tests moderation state config entity.

Namespace

Drupal\workbench_moderation\Tests

Code

public function testStateAdministration() {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/structure/workbench-moderation');
  $this
    ->assertLink('Moderation states');
  $this
    ->assertLink('Moderation state transitions');
  $this
    ->clickLink('Moderation states');
  $this
    ->assertLink('Add Moderation state');
  $this
    ->assertText('Draft');

  // Edit the draft.
  $this
    ->clickLink('Edit', 1);
  $this
    ->assertFieldByName('label', 'Draft');
  $this
    ->assertNoFieldChecked('edit-published');
  $this
    ->drupalPostForm(NULL, [
    'label' => 'Drafty',
  ], t('Save'));
  $this
    ->assertText('Saved the Drafty Moderation state.');
  $this
    ->drupalGet('admin/structure/workbench-moderation/states/draft');
  $this
    ->assertFieldByName('label', 'Drafty');
  $this
    ->drupalPostForm(NULL, [
    'label' => 'Draft',
  ], t('Save'));
  $this
    ->assertText('Saved the Draft Moderation state.');
  $this
    ->clickLink(t('Add Moderation state'));
  $this
    ->drupalPostForm(NULL, [
    'label' => 'Expired',
    'id' => 'expired',
  ], t('Save'));
  $this
    ->assertText('Created the Expired Moderation state.');
  $this
    ->drupalGet('admin/structure/workbench-moderation/states/expired');
  $this
    ->clickLink('Delete');
  $this
    ->assertText('Are you sure you want to delete Expired?');
  $this
    ->drupalPostForm(NULL, [], t('Delete'));
  $this
    ->assertText('Moderation state Expired deleted');
}