You are here

public function NodeTest::testUpdateModerationStateFuture in Scheduled Publish 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/NodeTest.php \Drupal\Tests\scheduled_publish\Kernel\NodeTest::testUpdateModerationStateFuture()

File

tests/src/Kernel/NodeTest.php, line 115

Class

NodeTest
Class NodeTests

Namespace

Drupal\Tests\scheduled_publish\Kernel

Code

public function testUpdateModerationStateFuture() {
  $page = Node::create([
    'type' => 'page',
    'title' => 'A',
  ]);
  $page->moderation_state->value = 'draft';
  $page
    ->set('field_scheduled_publish', [
    'moderation_state' => 'published',
    'value' => '2100-12-24T18:21Z',
  ]);
  $page
    ->save();
  $nodeID = $page
    ->id();
  self::assertTrue($nodeID);
  $this->scheduledUpdateService
    ->doUpdate();
  $loadedNode = Node::load($nodeID);
  self::assertEquals('draft', $loadedNode->moderation_state->value);
}