You are here

public function ViewsThemeIntegrationTest::testThemedViewPage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/ViewsThemeIntegrationTest.php \Drupal\views\Tests\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/src/Tests/ViewsThemeIntegrationTest.php, line 51
Contains \Drupal\views\Tests\ViewsThemeIntegrationTest.

Class

ViewsThemeIntegrationTest
Tests the Views theme integration.

Namespace

Drupal\views\Tests

Code

public function testThemedViewPage() {
  \Drupal::service('theme_handler')
    ->install(array(
    'test_basetheme',
    'test_subtheme',
  ));

  // Make base theme default then test for hook invocations.
  $this
    ->config('system.theme')
    ->set('default', 'test_basetheme')
    ->save();
  $this
    ->assertEqual($this
    ->config('system.theme')
    ->get('default'), 'test_basetheme');

  // Make sure a views rendered page is touched.
  $this
    ->drupalGet('test_page_display_200');
  $this
    ->assertRaw("test_basetheme_views_pre_render", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
  $this
    ->assertRaw("test_basetheme_views_post_render", "Views title changed by test_basetheme.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
    ->assertEqual($this
    ->config('system.theme')
    ->get('default'), 'test_subtheme');

  // Make sure a views rendered page is touched.
  $this
    ->drupalGet('test_page_display_200');
  $this
    ->assertRaw("test_subtheme_views_pre_render", "Views title changed by test_subtheme.test_subtheme_views_pre_render");
  $this
    ->assertRaw("test_subtheme_views_post_render", "Views title changed by test_subtheme.test_subtheme_views_post_render");
  $this
    ->assertRaw("test_basetheme_views_pre_render", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
  $this
    ->assertRaw("test_basetheme_views_post_render", "Views title changed by test_basetheme.test_basetheme_views_post_render");
  $this
    ->assertRaw('<em class="placeholder">' . count($this
    ->dataSet()) . '</em> items found.', 'Views group title added by test_subtheme.test_subtheme_views_post_render');
}