function ViewsViewFieldStatusTest::setUp

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides ViewsKernelTestBase::setUp

File

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

Class

ViewsViewFieldStatusTest
Tests the publication status marker of views status fields.

Namespace

Drupal\Tests\default_admin\Kernel

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp(FALSE);
  $this->installEntitySchema('user');
  $this->installEntitySchema('node');
  $this->installEntitySchema('taxonomy_term');
  $this->installSchema('node', [
    'node_access',
  ]);
  $this->installConfig([
    'filter',
    'language',
    'node',
  ]);
  // The translation language renderer only adds the language code of the row
  // to the query when the site is multilingual.
  // @see \Drupal\views\Entity\Render\TranslationLanguageRenderer::query()
  ConfigurableLanguage::createFromLangcode('es')->save();
  NodeType::create([
    'type' => 'page',
    'name' => 'Page',
  ])->save();
  $this->vocabulary = $this->createVocabulary();
  // Unpublished rows are only returned when node access is bypassed.
  $this->setUpCurrentUser([], [
    'access content',
    'administer taxonomy',
    'bypass node access',
  ]);
  // Install and activate the theme, so that its template and its preprocess
  // implementation are used while rendering. Installing the theme rebuilds
  // the container, which is what registers the
  // #[Hook('preprocess_views_view_field__status')] implementation of the
  // theme.
  // @see \Drupal\Core\Hook\ThemeHookCollectorPass
  \Drupal::service('theme_installer')->install([
    'default_admin',
  ]);
  $this->container = \Drupal::getContainer();
  \Drupal::theme()->setActiveTheme(\Drupal::service(ThemeInitializationInterface::class)->initTheme('default_admin'));
}

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