You are here

public function ModeratedContentSchedulingTest::testPublishOfDraft in Thunder 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModeratedContentSchedulingTest::testPublishOfDraft()
  2. 8.4 tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModeratedContentSchedulingTest::testPublishOfDraft()
  3. 6.2.x tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModeratedContentSchedulingTest::testPublishOfDraft()
  4. 6.0.x tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModeratedContentSchedulingTest::testPublishOfDraft()
  5. 6.1.x tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModeratedContentSchedulingTest::testPublishOfDraft()

Tests publish scheduling for a draft of a published node.

File

tests/src/FunctionalJavascript/ModeratedContentSchedulingTest.php, line 108

Class

ModeratedContentSchedulingTest
Tests publishing/unpublishing scheduling for moderated nodes.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testPublishOfDraft() {
  $this
    ->articleFillNew([
    'field_channel' => 1,
    'title[0][value]' => 'Test workflow article 3 - Published',
    'field_seo_title[0][value]' => 'Massive gaining seo traffic text 3',
    'moderation_state[0]' => 'published',
  ]);
  $this
    ->clickSave();
  $node = $this
    ->getNodeByTitle('Test workflow article 3 - Published');
  $nid = $node
    ->id();

  // Assert node is published.
  $this
    ->assertEquals('Test workflow article 3 - Published', Node::load($nid)
    ->getTitle());

  // Create a new pending revision and validate it's not the default published
  // one.
  $node
    ->setTitle('Test workflow article 3 - Draft');
  $node
    ->set('publish_on', strtotime('yesterday'));
  $node
    ->set('moderation_state', 'draft');
  $node
    ->set('publish_state', 'published');
  $node
    ->save();
  $revision_id = $node
    ->getRevisionId();

  // Test latest revision is not the published one.
  $this
    ->assertEquals('Test workflow article 3 - Published', Node::load($nid)
    ->getTitle());
  $this->container
    ->get('cron')
    ->run();

  // Test latest revision is now the published one.
  $this
    ->assertEquals('Test workflow article 3 - Draft', Node::load($nid)
    ->getTitle());

  // Assert only one revision is created during the operation.
  $this
    ->assertEquals($revision_id + 1, Node::load($node
    ->id())
    ->getRevisionId());
}