function ViewsViewFieldStatusTest::testNodeTranslationPublicationState

Tests that the marker of a node row follows the row translation.

File

core/themes/default_admin/tests/src/Kernel/ViewsViewFieldStatusTest.php, line 127

Class

ViewsViewFieldStatusTest
Tests the publication status marker of views status fields.

Namespace

Drupal\Tests\default_admin\Kernel

Code

public function testNodeTranslationPublicationState() : void {
  $node = Node::create([
    'type' => 'page',
    'title' => 'Published in English',
    'status' => TRUE,
  ]);
  $node->addTranslation('es', [
    'title' => 'Unpublished Spanish translation',
    'status' => FALSE,
  ]);
  $node->save();
  $this->createStatusView('test_node_translation_status', 'node', 'status', '***LANGUAGE_entity_translation***');
  $view = Views::getView('test_node_translation_status');
  $this->executeView($view);
  // The data table holds one row per translation.
  $this->assertCount(2, $view->result);
  $this->assertSame([
    'marker' => 'draft',
    'marker marker--published' => 'live',
  ], $this->renderStatusFieldByMarker($view));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.