diff --git a/core/modules/views/tests/modules/views_test_rss/views_test_rss.info.yml b/core/modules/views/tests/modules/views_test_rss/views_test_rss.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..3cc94385f0e61a71de879b67ed80a23bfb0f640a --- /dev/null +++ b/core/modules/views/tests/modules/views_test_rss/views_test_rss.info.yml @@ -0,0 +1,6 @@ +name: 'Views Test RSS' +type: module +description: 'Provides hooks to alter RSS output for testing purposes.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/views/tests/modules/views_test_rss/views_test_rss.module b/core/modules/views/tests/modules/views_test_rss/views_test_rss.module new file mode 100644 index 0000000000000000000000000000000000000000..5df73da91feca81b11e335de3c13d8d9eb1a3e5f --- /dev/null +++ b/core/modules/views/tests/modules/views_test_rss/views_test_rss.module @@ -0,0 +1,17 @@ +<?php + +/** + * @file + * Hook implementations for this module. + */ + +/** + * Implements hook_preprocess_HOOK(). + */ +function views_test_rss_preprocess_views_view_rss(&$variables) { + $variables['channel_elements'][] = [ + '#type' => 'html_tag', + '#tag' => 'copyright', + '#value' => t('Copyright 2019 Dries Buytaert'), + ]; +} diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php index 354ca7b4e03b406aa45da81e6665000021708861..1b6215da26789b525faaa5c635b7bbe2ea1c0fab 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php @@ -26,7 +26,7 @@ class DisplayFeedTest extends ViewTestBase { * * @var array */ - public static $modules = ['block', 'node', 'views']; + public static $modules = ['block', 'node', 'views', 'views_test_rss']; protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); @@ -63,6 +63,7 @@ public function testFeedOutput() { $this->drupalGet('test-feed-display.xml'); $this->assertEquals($site_name, $this->getSession()->getDriver()->getText('//title')); $this->assertEquals($frontpage_url, $this->getSession()->getDriver()->getText('//link')); + $this->assertEquals('Copyright 2019 Dries Buytaert', $this->getSession()->getDriver()->getText('//channel/copyright')); $this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title')); // Verify HTML is properly escaped in the description field. $this->assertRaw('<p>A paragraph</p>'); diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 82e4daa570ec7c2e4de15104ee004f3ac61eb871..e7ae6ad267256036e987feb28ef87dddefeeb49c 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -870,7 +870,7 @@ function template_preprocess_views_view_rss(&$variables) { $variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId(); $variables['namespaces'] = new Attribute($style->namespaces); $variables['items'] = $items; - $variables['channel_elements'] = \Drupal::service('renderer')->render($style->channel_elements); + $variables['channel_elements'] = $style->channel_elements; // During live preview we don't want to output the header since the contents // of the feed are being displayed inside a normal HTML page.