function PromotedContentViewTestTrait::enablePromotedContentView

Enables the promoted_content view and optionally rebuilds the router.

The promoted_content view is disabled by default so tests that rely on the front page or RSS feed provided by this view need to explicitly enable it and rebuild the router so the routes become available.

Parameters

bool $rebuildRouter: Whether to rebuild the router after enabling the view. Defaults to TRUE.

Return value

\Drupal\views\Entity\View The enabled view entity.

19 calls to PromotedContentViewTestTrait::enablePromotedContentView()
AjaxPageStateTest::setUp in core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
BreadcrumbTest::setUp in core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
CommentLinksTest::testCommentLinks in core/modules/comment/tests/src/Functional/CommentLinksTest.php
Tests that comment links are output and can be hidden.
CommentRssTest::setUp in core/modules/comment/tests/src/Functional/CommentRssTest.php
ConfigTranslationUiModulesTest::testViewsTranslationUI in core/modules/config_translation/tests/src/Functional/ConfigTranslationUiModulesTest.php
Tests the views translation interface.

... See full list

File

core/modules/node/tests/src/Traits/PromotedContentViewTestTrait.php, line 28

Class

PromotedContentViewTestTrait
Provides a method to enable the promoted_content view.

Namespace

Drupal\Tests\node\Traits

Code

protected function enablePromotedContentView(bool $rebuildRouter = TRUE) {
  $view = \Drupal::entityTypeManager()->getStorage('view')
    ->load('promoted_content');
  $view->enable()
    ->save();
  if ($rebuildRouter) {
    \Drupal::service('router.builder')->rebuild();
  }
  return $view;
}

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