You are here

public function CommonTest::testUpdateModerationState in Scheduled Publish 8

File

tests/src/Kernel/CommonTest.php, line 87

Class

CommonTest
Class CommonTest

Namespace

Drupal\Tests\scheduled_publish\Kernel

Code

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