You are here

public function ArticleCreationTest::testModerationWorkflow in Thunder 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()
  2. 8.2 tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()
  3. 8.3 tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()
  4. 6.2.x tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()
  5. 6.0.x tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()
  6. 6.1.x tests/src/FunctionalJavascript/ArticleCreationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ArticleCreationTest::testModerationWorkflow()

Tests draft creation and that reverting to the default revision works.

File

tests/src/FunctionalJavascript/ArticleCreationTest.php, line 146

Class

ArticleCreationTest
Tests the article creation.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testModerationWorkflow() {
  $this
    ->articleFillNew([
    'field_channel' => 1,
    'title[0][value]' => 'Test workflow article',
    'field_seo_title[0][value]' => 'Massive gaining seo traffic text',
  ]);
  $this
    ->setModerationState('published');
  $this
    ->clickSave();
  $this
    ->assertPageTitle('Massive gaining seo traffic text');
  $node = $this
    ->getNodeByTitle('Test workflow article');
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->setModerationState('unpublished');
  $this
    ->getSession()
    ->getPage()
    ->find('xpath', '//*[@id="edit-preview"]')
    ->click();
  $this
    ->clickLink('Back to content editing');
  $this
    ->assertSession()
    ->pageTextNotContains('An illegal choice has been detected. Please contact the site administrator.');
  $this
    ->setFieldValues($this
    ->getSession()
    ->getPage(), [
    'title[0][value]' => 'Test workflow article in draft',
    'field_seo_title[0][value]' => 'Massive gaining even more seo traffic text',
  ]);
  $this
    ->setModerationState('draft');
  $this
    ->clickSave();
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->setFieldValues($this
    ->getSession()
    ->getPage(), [
    'title[0][value]' => 'Test workflow article in draft 2',
    'field_seo_title[0][value]' => 'Massive gaining even more and more seo traffic text',
  ]);
  $this
    ->setModerationState('draft');
  $this
    ->clickSave();
  $this
    ->assertPageTitle('Massive gaining even more and more seo traffic text');

  /** @var \Drupal\node\NodeStorageInterface $node_storage */
  $node_storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $revert_url = Url::fromRoute('node.revision_revert_default_confirm', [
    'node' => $node
      ->id(),
    'node_revision' => $node_storage
      ->getLatestRevisionId($node
      ->id()),
  ]);
  $this
    ->drupalPostForm($revert_url, [], $this
    ->t('Revert'));
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->assertPageTitle('Massive gaining seo traffic text');
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->assertSession()
    ->fieldValueEquals('field_seo_title[0][value]', 'Massive gaining seo traffic text');
}