function ViewsViewFieldStatusTest::testTermTranslationPublicationState

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

This covers the regression the template logic was moved into a preprocess implementation for. The template used to read the row translation from the row property node_field_data_langcode, which is the language code alias of a node based view. On a taxonomy term view that property does not exist, so the default translation was used and this row got the marker of a published term while its output said the term was unpublished.

File

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

Class

ViewsViewFieldStatusTest
Tests the publication status marker of views status fields.

Namespace

Drupal\Tests\default_admin\Kernel

Code

public function testTermTranslationPublicationState() : void {
  $term = Term::create([
    'vid' => $this->vocabulary
      ->id(),
    'name' => 'Published in English',
    'status' => TRUE,
  ]);
  $term->addTranslation('es', [
    'name' => 'Unpublished Spanish translation',
    'status' => FALSE,
  ]);
  $term->save();
  $this->createStatusView('test_term_translation_status', 'taxonomy_term', 'status', '***LANGUAGE_entity_translation***');
  $view = Views::getView('test_term_translation_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.