public function ViewsDataIntegrationTest::testContentModerationStateRevisionJoin in Drupal 8
Tests the join from the revision data table to the moderation state table.
File
- core/
modules/ content_moderation/ tests/ src/ Kernel/ ViewsDataIntegrationTest.php, line 60
Class
- ViewsDataIntegrationTest
- Tests the views integration of content_moderation.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testContentModerationStateRevisionJoin() {
$node = Node::create([
'type' => 'page',
'title' => 'Test title first revision',
]);
$node->moderation_state->value = 'published';
$node
->save();
$revision = clone $node;
$revision
->setNewRevision(TRUE);
$revision
->isDefaultRevision(FALSE);
$revision->title->value = 'Test title second revision';
$revision->moderation_state->value = 'draft';
$revision
->save();
$view = Views::getView('test_content_moderation_revision_test');
$view
->execute();
$expected_result = [
[
'vid' => $node
->getRevisionId(),
'moderation_state' => 'published',
],
[
'vid' => $revision
->getRevisionId(),
'moderation_state' => 'draft',
],
];
$this
->assertIdenticalResultset($view, $expected_result, [
'vid' => 'vid',
'moderation_state' => 'moderation_state',
]);
}