You are here

public function MediaTest::testUpdateModerationStateFuture in Scheduled Publish 8.3

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

File

tests/src/Kernel/MediaTest.php, line 114

Class

MediaTest
Class MediaTests

Namespace

Drupal\Tests\scheduled_publish\Kernel

Code

public function testUpdateModerationStateFuture() {
  $entity = Media::create([
    'bundle' => $this->testMediaType
      ->id(),
    'title' => 'A',
    'field_media_test' => 'something',
  ]);
  $entity->moderation_state->value = 'draft';
  $entity
    ->set('field_scheduled_publish', [
    'moderation_state' => 'published',
    'value' => '2100-12-24T18:21Z',
  ]);
  $entity
    ->save();
  $id = $entity
    ->id();
  self::assertTrue((bool) $id);
  $this->scheduledUpdateService
    ->doUpdate();
  $loadedMedia = Media::load($id);
  self::assertEquals('draft', $loadedMedia->moderation_state->value);
}