You are here

public function ModeratedContentSchedulingTest::testUnpublishStateSchedule in Thunder 6.1.x

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

Tests moderated nodes unpublish scheduling.

File

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

Class

ModeratedContentSchedulingTest
Tests publishing/unpublishing scheduling for moderated nodes.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testUnpublishStateSchedule() {
  $term = $this
    ->loadTermByUuid('bfc251bc-de35-467d-af44-1f7a7012b845');
  $this
    ->articleFillNew([
    'field_channel' => $term
      ->id(),
    'title[0][value]' => 'Test workflow article 2 - Published',
    'field_seo_title[0][value]' => 'Massive gaining seo traffic text 2',
    'moderation_state[0]' => 'published',
    'unpublish_on[0][value][date]' => date('Y-m-d', strtotime('tomorrow')),
    'unpublish_state[0]' => 'unpublished',
  ]);
  $this
    ->clickSave();
  $node = $this
    ->getNodeByTitle('Test workflow article 2 - Published');

  // Set date manually, unpublish cannot be in the past.
  $node->unpublish_on->value = strtotime('yesterday');
  $node
    ->save();
  $revision_id = $node
    ->getRevisionId();

  // Make sure node is published.
  $this
    ->assertEquals(TRUE, Node::load($node
    ->id())
    ->isPublished());
  $this->container
    ->get('cron')
    ->run();

  // Assert node is now unpublished.
  $this
    ->assertEquals(FALSE, Node::load($node
    ->id())
    ->isPublished());

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