class ViewsThemeIntegrationTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php \Drupal\Tests\views\Functional\ViewsThemeIntegrationTest
- 10 core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php \Drupal\Tests\views\Functional\ViewsThemeIntegrationTest
- 8.9.x core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php \Drupal\Tests\views\Functional\ViewsThemeIntegrationTest
Tests the Views theme integration.
We test against test_basetheme and test_subtheme provided by theme_test
@group views
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\views\Functional\ViewsThemeIntegrationTest extends \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ViewsThemeIntegrationTest
File
-
core/
modules/ views/ tests/ src/ Functional/ ViewsThemeIntegrationTest.php, line 12
Namespace
Drupal\Tests\views\FunctionalView source
class ViewsThemeIntegrationTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_page_display',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*
* We need theme_test for testing against test_basetheme and test_subtheme.
*
* @var array
*
* {@inheritdoc}
*/
protected static $modules = [
'views',
'theme_test',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp($import_test_views, $modules);
$this->enableViewsTestModule();
}
/**
* Tests pre_render and post_render hooks in a theme and sub-theme.
*/
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.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.