--- 2409417-44.patch 2015-02-15 10:54:24.000000000 +1100 +++ 2409417-46.patch 2015-02-15 12:10:45.000000000 +1100 @@ -1,5 +1,88 @@ +diff --git a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php +index e1cd4ec..756f6c0 100644 +--- a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php ++++ b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php +@@ -20,12 +20,22 @@ class DisplayAttachmentTest extends PluginTestBase { + * + * @var array + */ +- public static $testViews = array('test_display_attachment'); ++ public static $testViews = array('test_display_attachment', 'test_attached_disabled'); ++ ++ /** ++ * Modules to enable. ++ * ++ * @var array ++ */ ++ public static $modules = array('node', 'views'); + + protected function setUp() { + parent::setUp(); + + $this->enableViewsTestModule(); ++ ++ $admin_user = $this->drupalCreateUser(array('administer site configuration')); ++ $this->drupalLogin($admin_user); + } + + +@@ -45,4 +55,54 @@ protected function testAttachment() { + $this->assertEqual(count($result), 1, 'The attachment is rendered before the actual view.'); + } + ++ /** ++ * Tests that nothing is output when the attachment displays are disabled. ++ */ ++ public function testDisabledAttachments() { ++ $this->drupalCreateContentType(['type' => 'page']); ++ $node = $this->drupalCreateNode(); ++ ++ // Ensure that the feed_1 display is attached to the page_1 display. ++ $view = $this->container->get('entity.manager')->getStorage('view')->load('test_attached_disabled'); ++ $view->getExecutable()->setDisplay('page_1'); ++ $attached_displays = $view->getExecutable()->display_handler->getAttachedDisplays(); ++ $this->assertTrue(in_array('attachment_1', $attached_displays), 'The attachment_1 display is attached to the page display.'); ++ $this->assertTrue(in_array('attachment_2', $attached_displays), 'The attachment_2 display is attached to the page display.'); ++ ++ // Check that the attachments are output on the page display. ++ $this->drupalGet('test-attached-disabled'); ++ ++ $result = $this->xpath('//div[contains(@class, "view-content")]'); ++ $this->assertEqual(count($result), 3, 'Both actual view and the attachment is rendered.'); ++ ++ $result = $this->xpath('//div[contains(@class, "attachment-before")]'); ++ $this->assertEqual(count($result), 1, 'The attachment is rendered before the actual view.'); ++ ++ $result = $this->xpath('//div[contains(@class, "attachment-after")]'); ++ $this->assertEqual(count($result), 1, 'The attachment is rendered after the actual view.'); ++ ++ // Disable the attachment_1 display. ++ $view->getExecutable()->displayHandlers->get('attachment_1')->setOption('enabled', FALSE); ++ $view->save(); ++ ++ // Test that the before attachment is not displayed. ++ $this->drupalGet('/test-attached-disabled'); ++ $result = $this->xpath('//div[contains(@class, "view-content")]'); ++ $this->assertEqual(count($result), 2, 'The page view and only one attachment are rendered.'); ++ ++ $result = $this->xpath('//div[contains(@class, "attachment-before")]'); ++ $this->assertEqual(count($result), 0, 'The attachment_1 is not rendered.'); ++ ++ // Disable the attachment_2 display. ++ $view->getExecutable()->displayHandlers->get('attachment_2')->setOption('enabled', FALSE); ++ $view->save(); ++ ++ // Test that the after attachment is not displayed. ++ $this->drupalGet('/test-attached-disabled'); ++ $result = $this->xpath('//div[contains(@class, "view-content")]'); ++ $this->assertEqual(count($result), 1, 'The page view is rendered without attachments.'); ++ ++ $result = $this->xpath('//div[contains(@class, "attachment-after")]'); ++ $this->assertEqual(count($result), 0, 'The attachment_2 is not rendered.'); ++ } + } diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php -index cef9bab..0a23f40 100644 +index cef9bab..e5fdc55 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php @@ -20,7 +20,7 @@ class DisplayFeedTest extends PluginTestBase { @@ -7,7 +90,7 @@ * @var array */ - public static $testViews = array('test_display_feed'); -+ public static $testViews = array('test_display_feed', 'test_disabled_feed'); ++ public static $testViews = array('test_display_feed', 'test_attached_disabled'); /** * Modules to enable. @@ -23,12 +106,12 @@ + $node = $this->drupalCreateNode(); + + // Ensure that the feed_1 display is attached to the page_1 display. -+ $view = $this->container->get('entity.manager')->getStorage('view')->load('test_disabled_feed'); ++ $view = $this->container->get('entity.manager')->getStorage('view')->load('test_attached_disabled'); + $view->getExecutable()->setDisplay('page_1'); + $this->assertEqual($view->getExecutable()->display_handler->getAttachedDisplays(), array('feed_1'), 'The feed display is attached to the page display.'); + + // Check that the rss header is output on the page display. -+ $this->drupalGet('/test-feed-disabled'); ++ $this->drupalGet('/test-attached-disabled'); + $feed_header = $this->xpath('//link[@rel="alternate"]'); + $this->assertEqual($feed_header[0]['type'], 'application/rss+xml', 'The feed link has the type application/rss+xml.'); + $this->assertTrue(strpos($feed_header[0]['href'], 'test-feed-disabled.xml'), 'Page display contains the correct feed URL.'); @@ -38,20 +121,20 @@ + $view->save(); + + // Ensure there is no link rel present on the page. -+ $this->drupalGet('/test-feed-disabled'); ++ $this->drupalGet('/test-attached-disabled'); + $result = $this->xpath('//link[@rel="alternate"]'); + $this->assertTrue(empty($result), 'Page display does not contain a feed header.'); + + // Ensure the feed attachment returns 'Not found'. -+ $this->drupalGet('/test-feed-disabled.xml'); ++ $this->drupalGet('/test-attached-disabled.xml'); + $this->assertResponse(404); + } } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php -index 9791a88..23c4f4f 100644 +index db01ad8..d95161f 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php -@@ -1537,8 +1537,12 @@ public function attachDisplays() { +@@ -1549,8 +1549,12 @@ public function attachDisplays() { $this->is_attachment = TRUE; // Find out which other displays attach to the current one. foreach ($this->display_handler->getAttachedDisplays() as $id) { @@ -66,12 +149,12 @@ } $this->is_attachment = FALSE; } -diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_disabled_feed.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_disabled_feed.yml +diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_attached_disabled.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_attached_disabled.yml new file mode 100644 -index 0000000..edabfd8 +index 0000000..af3c1ba --- /dev/null -+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_disabled_feed.yml -@@ -0,0 +1,176 @@ ++++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_attached_disabled.yml +@@ -0,0 +1,219 @@ +langcode: und +status: true +dependencies: @@ -80,9 +163,9 @@ + module: + - node + - user ++id: test_attached_disabled ++label: test_attached_disabled +module: views -+id: test_disabled_feed -+label: test_disabled_feed +description: '' +tag: '' +base_table: node @@ -108,7 +191,7 @@ + disable_sql_rewrite: false + distinct: false + replica: false -+ query_comment: false ++ query_comment: '' + query_tags: { } + exposed_form: + type: basic @@ -217,27 +300,72 @@ + relationships: { } + arguments: { } + display_extenders: { } -+ field_langcode: '***LANGUAGE_language_content***' -+ field_langcode_add_to_query: null ++ attachment_1: ++ display_plugin: attachment ++ id: attachment_1 ++ display_title: 'Attachment Before' ++ position: 2 ++ display_options: ++ display_extenders: { } ++ pager: ++ type: some ++ style: ++ type: rss ++ row: ++ type: node_rss ++ displays: ++ page_1: page_1 ++ default: '0' ++ attachment_position: before ++ enabled: true ++ title: Attachment Before ++ defaults: ++ title: false ++ display_description: '' ++ attachment_2: ++ display_plugin: attachment ++ id: attachment_2 ++ display_title: 'Attachment After' ++ position: 2 ++ display_options: ++ display_extenders: { } ++ pager: ++ type: some ++ style: ++ type: rss ++ row: ++ type: node_rss ++ displays: ++ page_1: page_1 ++ default: '0' ++ attachment_position: after ++ enabled: true ++ title: Attachment After ++ defaults: ++ title: false ++ display_description: '' + feed_1: + display_plugin: feed + id: feed_1 + display_title: Feed -+ position: 2 ++ position: 5 + display_options: + display_extenders: { } -+ field_langcode: '***LANGUAGE_language_content***' -+ field_langcode_add_to_query: null + pager: + type: some + style: + type: rss + row: + type: node_rss -+ path: test-feed-disabled.xml ++ path: test-attached-disabled.xml + displays: + page_1: page_1 + default: '0' ++ enabled: true ++ title: Feed ++ defaults: ++ title: false ++ sitename_title: false + page_1: + display_plugin: page + id: page_1 @@ -245,14 +373,12 @@ + position: 1 + display_options: + display_extenders: { } -+ field_langcode: '***LANGUAGE_language_content***' -+ field_langcode_add_to_query: null -+ path: test-feed-disabled ++ path: test-attached-disabled diff --git a/core/modules/views/tests/src/Unit/ViewExecutableTest.php b/core/modules/views/tests/src/Unit/ViewExecutableTest.php -index ecabe3f..af9b304 100644 +index d980f82..ffa9306 100644 --- a/core/modules/views/tests/src/Unit/ViewExecutableTest.php +++ b/core/modules/views/tests/src/Unit/ViewExecutableTest.php -@@ -242,6 +242,10 @@ public function testAttachDisplays() { +@@ -414,6 +414,10 @@ public function testAttachDisplays() { ->disableOriginalConstructor() ->getMock();