function ViewsViewFieldStatusTest::testNodePublicationState

Tests the marker of published and unpublished nodes.

File

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

Class

ViewsViewFieldStatusTest
Tests the publication status marker of views status fields.

Namespace

Drupal\Tests\default_admin\Kernel

Code

public function testNodePublicationState() : void {
  Node::create([
    'type' => 'page',
    'title' => 'Published node',
    'status' => TRUE,
  ])->save();
  Node::create([
    'type' => 'page',
    'title' => 'Unpublished node',
    'status' => FALSE,
  ])->save();
  $this->createStatusView('test_node_status', 'node', 'status');
  $view = Views::getView('test_node_status');
  $this->executeView($view);
  $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.