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 95c2291..e72339a 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 @@ public function optionsSummary(&$categories, &$options) { } elseif (count($displays) == 1) { $display = array_shift($displays); - if (!empty($this->view->storage->display[$display])) { - $attach_to = check_plain($this->view->storage->display[$display]['display_title']); + if ($display = $this->view->storage->getDisplay($display)) { + $attach_to = check_plain($display['display_title']); } } diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php index 0f26c3f..ac92b78 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/DisplayAttachmentTest.php @@ -36,18 +36,32 @@ 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'); + $attachment_display_url = 'admin/structure/views/nojs/display/test_attachment_ui/attachment_1/displays'; + $this->drupalGet($attachment_display_url); 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->drupalGet($attachment_display_url); + $this->drupalPost(NULL, array('displays[page_1]' => 1), t('Apply')); + $result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays')); + $this->assertEqual($result[0]->attributes()->title, t('Page')); + $this->drupalPost(NULL, array(), t('Save')); + + $view = views_get_view('test_attachment_ui'); + $view->initDisplay(); + debug(array_keys($view->displayHandlers['attachment_1']->getOption('displays'))); + $this->assertEqual(array_keys(array_filter($view->displayHandlers['attachment_1']->getOption('displays'))), array('page_1'), 'The attached displays got saved as expected'); + + $this->drupalGet($attachment_display_url); $this->drupalPost(NULL, array('displays[default]' => 1, 'displays[page_1]' => 1), t('Apply')); + $result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays')); + $this->assertEqual($result[0]->attributes()->title, t('Multiple displays')); $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'); + $this->assertEqual(array_keys(array_filter($view->displayHandlers['attachment_1']->getOption('displays'))), array('default', 'page_1'), 'The attached displays got saved as expected'); } }