public function MediaTest::testUpdateModerationState in Scheduled Publish 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/MediaTest.php \Drupal\Tests\scheduled_publish\Kernel\MediaTest::testUpdateModerationState()
File
- tests/
src/ Kernel/ MediaTest.php, line 88
Class
- MediaTest
- Class MediaTests
Namespace
Drupal\Tests\scheduled_publish\KernelCode
public function testUpdateModerationState() {
$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' => '2007-12-24T18:21Z',
]);
$entity
->save();
$id = $entity
->id();
self::assertTrue($id);
$this->scheduledUpdateService
->doUpdate();
$loadedMedia = Media::load($id);
self::assertEquals('published', $loadedMedia->moderation_state->value);
}