public function ModeratedContentSchedulingTest::testUnpublishStateSchedule in Thunder 8.2
Tests moderated nodes unpublish scheduling.
File
- tests/
src/ Kernel/ ModeratedContentSchedulingTest.php, line 64
Class
- ModeratedContentSchedulingTest
- Tests publishing/unpublishing scheduling for moderated nodes.
Namespace
Drupal\Tests\thunder\KernelCode
public function testUnpublishStateSchedule() {
$node = Node::create([
'type' => 'example',
'title' => 'Published title',
'moderation_state' => 'published',
'unpublish_on' => strtotime('yesterday'),
'unpublish_state' => 'archived',
]);
$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());
}