You are here

public function ViewsDataIntegrationTest::testContentModerationStateField in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php \Drupal\Tests\content_moderation\Kernel\ViewsDataIntegrationTest::testContentModerationStateField()

Tests the content moderation state views field.

File

core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php, line 59

Class

ViewsDataIntegrationTest
Tests the views integration of content_moderation.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

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',
  ]);
}