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.
2 calls to PromotedContentViewTestTrait::enablePromotedContentView()
- FileFieldRSSContentTest::testFileFieldRSSContent in core/
modules/ file/ tests/ src/ Functional/ FileFieldRSSContentTest.php - Tests RSS enclosure formatter display for RSS feeds.
- LocalePathTest::setUp in core/
modules/ locale/ tests/ src/ Functional/ LocalePathTest.php
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\TraitsCode
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.