function ViewsViewFieldStatusTest::testTermPublicationState

Tests the marker of a publishable entity type other than the node type.

File

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

Class

ViewsViewFieldStatusTest
Tests the publication status marker of views status fields.

Namespace

Drupal\Tests\default_admin\Kernel

Code

public function testTermPublicationState() : void {
  Term::create([
    'vid' => $this->vocabulary
      ->id(),
    'name' => 'Published term',
    'status' => TRUE,
  ])
    ->save();
  Term::create([
    'vid' => $this->vocabulary
      ->id(),
    'name' => 'Unpublished term',
    'status' => FALSE,
  ])
    ->save();
  $this->createStatusView('test_term_status', 'taxonomy_term', 'status');
  $view = Views::getView('test_term_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.