public function ViewsThemeIntegrationTest::testThemedViewPage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php \Drupal\Tests\views\Functional\ViewsThemeIntegrationTest::testThemedViewPage()
Tests for exceptions and successful execution of hook_views_pre_render() and hook_views_post_render() in theme and subtheme.
File
- core/
modules/ views/ tests/ src/ Functional/ ViewsThemeIntegrationTest.php, line 51
Class
- ViewsThemeIntegrationTest
- Tests the Views theme integration.
Namespace
Drupal\Tests\views\FunctionalCode
public function testThemedViewPage() {
\Drupal::service('theme_installer')
->install([
'test_basetheme',
'test_subtheme',
]);
// Make base theme default then test for hook invocations.
$this
->config('system.theme')
->set('default', 'test_basetheme')
->save();
$this
->assertEquals('test_basetheme', $this
->config('system.theme')
->get('default'));
// Make sure a views rendered page is touched.
$this
->drupalGet('test_page_display_200');
$this
->assertSession()
->responseContains("test_basetheme_views_pre_render");
$this
->assertSession()
->responseContains("test_basetheme_views_post_render");
// Make sub theme default to test for hook invocation
// from both sub and base theme.
$this
->config('system.theme')
->set('default', 'test_subtheme')
->save();
$this
->assertEquals('test_subtheme', $this
->config('system.theme')
->get('default'));
// Make sure a views rendered page is touched.
$this
->drupalGet('test_page_display_200');
$this
->assertSession()
->responseContains("test_subtheme_views_pre_render");
$this
->assertSession()
->responseContains("test_subtheme_views_post_render");
$this
->assertSession()
->responseContains("test_basetheme_views_pre_render");
$this
->assertSession()
->responseContains("test_basetheme_views_post_render");
// Verify that the views group title is added.
$this
->assertSession()
->responseContains('<em class="placeholder">' . count($this
->dataSet()) . '</em> items found.');
}