Mercurial > hg > isophonics-drupal-site
annotate core/modules/views/tests/src/Functional/ViewsTemplateTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Tests\views\Functional; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\views\Tests\ViewTestData; |
Chris@0 | 6 use Drupal\views\Views; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Tests the template retrieval of views. |
Chris@0 | 10 * |
Chris@0 | 11 * @group views |
Chris@0 | 12 * @see \Drupal\views_test_data\Plugin\views\style\StyleTemplateTest |
Chris@0 | 13 */ |
Chris@0 | 14 class ViewsTemplateTest extends ViewTestBase { |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * Views used by this test. |
Chris@0 | 18 * |
Chris@0 | 19 * @var array |
Chris@0 | 20 */ |
Chris@0 | 21 public static $testViews = ['test_view_display_template']; |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * {@inheritdoc} |
Chris@0 | 25 */ |
Chris@0 | 26 protected function setUp($import_test_views = TRUE) { |
Chris@0 | 27 parent::setUp(FALSE); |
Chris@0 | 28 |
Chris@0 | 29 $this->enableViewsTestModule(); |
Chris@0 | 30 ViewTestData::createTestViews(get_class($this), ['views_test_config']); |
Chris@0 | 31 } |
Chris@0 | 32 |
Chris@0 | 33 /** |
Chris@0 | 34 * Tests render functionality. |
Chris@0 | 35 */ |
Chris@0 | 36 public function testTemplate() { |
Chris@0 | 37 |
Chris@0 | 38 // Make sure that the rendering just calls the preprocess function once. |
Chris@0 | 39 $view = Views::getView('test_view_display_template'); |
Chris@0 | 40 $output = $view->preview(); |
Chris@0 | 41 |
Chris@0 | 42 // Check if we got the rendered output of our template file. |
Chris@0 | 43 $this->assertTrue(strpos(\Drupal::service('renderer')->renderRoot($output), 'This module defines its own display template.') !== FALSE, 'Display plugin DisplayTemplateTest defines its own template.'); |
Chris@0 | 44 |
Chris@0 | 45 } |
Chris@0 | 46 |
Chris@0 | 47 } |