Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / content_moderation / tests / src / Kernel / ViewsDataIntegrationTest.php
index 125d68fbd2b0cfc6da877815137cc0773d181ae0..00e107295aad917fcf7ebaf8da514c000e0e17a9 100644 (file)
@@ -108,14 +108,12 @@ class ViewsDataIntegrationTest extends ViewsKernelTestBase {
     $expected_result = [
       [
         'nid' => $node->id(),
-        // @todo I would have expected that the content_moderation_state default
-        //   revision is the same one as in the node, but it isn't.
         // Joins from the base table to the default revision of the
         // content_moderation.
-        'moderation_state' => 'draft',
+        'moderation_state' => 'published',
         // Joins from the revision table to the default revision of the
         // content_moderation.
-        'moderation_state_1' => 'draft',
+        'moderation_state_1' => 'published',
         // Joins from the revision table to the revision of the
         // content_moderation.
         'moderation_state_2' => 'published',
@@ -124,4 +122,27 @@ class ViewsDataIntegrationTest extends ViewsKernelTestBase {
     $this->assertIdenticalResultset($view, $expected_result, ['nid' => 'nid', 'moderation_state' => 'moderation_state', 'moderation_state_1' => 'moderation_state_1', 'moderation_state_2' => 'moderation_state_2']);
   }
 
+  /**
+   * Tests the content moderation state views field.
+   */
+  public function testContentModerationStateField() {
+    $node = Node::create([
+      'type' => 'page',
+      'title' => 'Test title',
+    ]);
+    $node->moderation_state->value = 'published';
+    $node->save();
+
+    $view = Views::getView('test_content_moderation_field_state_test');
+    $view->execute();
+
+    $expected_result = [
+      [
+        'title' => 'Test title',
+        'moderation_state' => 'published',
+      ],
+    ];
+    $this->assertIdenticalResultset($view, $expected_result, ['title' => 'title', 'moderation_state' => 'moderation_state']);
+  }
+
 }