From 455a299a4d464c5836cc18e610ab1080f9a10686 Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 7 Jan 2013 11:17:57 +0000 Subject: [PATCH] Issue #1810812 by dawehner, damiankloip: Fixed Attachment is still using display on the view object. --- .../views/Plugin/views/display/Attachment.php | 10 +-- .../views/Tests/UI/DisplayAttachmentTest.php | 53 +++++++++++++++ .../views.view.test_attachment_ui.yml | 68 +++++++++++++++++++ 3 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php create mode 100644 core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php index cfd03a5ad4d..95c2291aca6 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php @@ -91,8 +91,8 @@ class Attachment extends DisplayPluginBase { } elseif (count($displays) == 1) { $display = array_shift($displays); - if (!empty($this->view->display[$display])) { - $attach_to = check_plain($this->view->display[$display]['display_title']); + if (!empty($this->view->storage->display[$display])) { + $attach_to = check_plain($this->view->storage->display[$display]['display_title']); } } @@ -194,7 +194,7 @@ class Attachment extends DisplayPluginBase { case 'displays': $form['#title'] .= t('Attach to'); $displays = array(); - foreach ($this->view->display as $display_id => $display) { + foreach ($this->view->storage->get('display') as $display_id => $display) { if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]->acceptAttachments()) { $displays[$display_id] = $display['display_title']; } @@ -246,8 +246,8 @@ class Attachment extends DisplayPluginBase { $view->setArguments($args); $view->setDisplay($this->display['id']); if ($this->getOption('inherit_pager')) { - $view->display_handler->usesPager = $this->view->display[$display_id]->handler->usesPager(); - $view->display_handler->setOption('pager', $this->view->display[$display_id]->handler->getOption('pager')); + $view->display_handler->usesPager = $this->view->displayHandlers[$display_id]->usesPager(); + $view->display_handler->setOption('pager', $this->view->displayHandlers[$display_id]->getOption('pager')); } $attachment = $view->executeDisplay($this->display['id'], $args); diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php new file mode 100644 index 00000000000..0f26c3f6966 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php @@ -0,0 +1,53 @@ + 'Display: Attachment', + 'description' => 'Tests the UI for the attachment display plugin.', + 'group' => 'Views UI', + ); + } + + /** + * Tests the attachment UI. + */ + public function testAttachmentUI() { + $this->drupalGet('admin/structure/views/view/test_attachment_ui/edit/attachment_1'); + $this->assertText(t('Not defined'), 'The right text appears if there is no attachment selection yet.'); + + $this->drupalGet('admin/structure/views/nojs/display/test_attachment_ui/attachment_1/displays'); + + foreach (array('default', 'page-1') as $display_id) { + $this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id))); + } + + // Save the attachments and test the value on the view. + $this->drupalPost(NULL, array('displays[default]' => 1, 'displays[page_1]' => 1), t('Apply')); + $this->drupalPost(NULL, array(), t('Save')); + + $view = views_get_view('test_attachment_ui'); + $view->initDisplay(); + $this->assertEqual(array_keys($view->displayHandlers['attachment_1']->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected'); + } +} diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml new file mode 100644 index 00000000000..3d3702e4a5b --- /dev/null +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_attachment_ui.yml @@ -0,0 +1,68 @@ +api_version: '3.0' +base_table: views_test_data +core: '8' +description: '' +disabled: '0' +display: + default: + display_options: + access: + type: perm + options: + perm: 'views_test_data test permission' + cache: + type: none + exposed_form: + type: basic + pager: + type: full + style: + type: default + row: + type: fields + fields: + id: + id: id + table: views_test_data + field: id + display_plugin: default + display_title: Master + id: default + position: '0' + attachment_1: + display_plugin: attachment + display_title: Attachment + id: attachment_1 + position: '1' + page_1: + display_plugin: page + display_title: Page + display_options: + path: test_attachment_ui + id: page_1 + position: '2' + feed_1: + display_plugin: feed + id: feed_1 + display_title: Feed + position: '' + display_options: + pager: + type: some + style: + type: rss + row: + type: rss_fields + options: + title_field: id + link_field: id + description_field: id + creator_field: id + date_field: id + guid_field_options: + guid_field: id + guid_field_is_permalink: '0' + path: test_attachment_ui_feed + position: '3' +name: test_attachment_ui +tag: ''