Commit 3397e905 authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1754536 by dawehner, xjm: Fixed The comment wizard doesn't use the...

Issue #1754536 by dawehner, xjm: Fixed The comment wizard doesn't use the right row plugin by default.
parent cfc06697
......@@ -836,7 +836,9 @@ protected function page_display_options($form, $form_state) {
$display_options['path'] = $page['path'];
$display_options['style_plugin'] = $page['style']['style_plugin'];
// Not every style plugin supports row style plugins.
$display_options['row_plugin'] = isset($page['style']['row_plugin']) ? $page['style']['row_plugin'] : 'fields';
// Make sure that the selected row plugin is a valid one.
$options = $this->row_style_options();
$display_options['row_plugin'] = (isset($page['style']['row_plugin']) && isset($options[$page['style']['row_plugin']])) ? $page['style']['row_plugin'] : 'fields';
if (empty($page['items_per_page'])) {
$display_options['pager']['type'] = 'none';
}
......
<?php
/**
* @file
* Definition of Drupal\views\Tests\Comment\WizardTest.
*/
namespace Drupal\views\Tests\Comment;
use Drupal\views\Tests\Wizard\WizardTestBase;
/**
* Tests the comment module integration into the wizard.
*
* @see Views\comment\Plugin\views\wizard\Comment
*/
class WizardTest extends WizardTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('comment');
public static function getInfo() {
return array(
'name' => 'Comment: Wizard',
'description' => 'Tests the comment module integration into the wizard.',
'group' => 'Views Wizard',
);
}
/**
* Tests adding a view of comments.
*/
public function testCommentWizard() {
$view = array();
$view['human_name'] = $this->randomName(16);
$view['name'] = strtolower($this->randomName(16));
$view['show[wizard_key]'] = 'comment';
$view['page[path]'] = $this->randomName(16);
// Just triggering the saving should automatically choose a proper row
// plugin.
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->assertUrl('admin/structure/views/view/' . $view['name'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
// If we update the type first we should get a selection of comment valid
// row plugins as the select field.
$this->drupalGet('admin/structure/views/add');
$this->drupalPost('admin/structure/views/add', $view, t('Update "of type" choice'));
// Check for available options of the row plugin.
$xpath = $this->constructFieldXpath('name', 'page[style][row_plugin]');
$fields = $this->xpath($xpath);
$options = array();
foreach ($fields as $field) {
$items = $this->getAllOptions($field);
foreach ($items as $item) {
$options[] = $item->attributes()->value;
}
}
$expected_options = array('comment', 'fields');
$this->assertEqual($options, $expected_options);
$this->drupalPost(NULL, $view, t('Continue & edit'));
$this->assertUrl('admin/structure/views/view/' . $view['name'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view['name']);
$view->initDisplay();
$view->initHandlers();
$this->assertEqual($view->display_handler->getOption('row_plugin'), 'comment');
// Check for the default filters.
$this->assertEqual($view->filter['status']->table, 'comment');
$this->assertEqual($view->filter['status']->field, 'status');
$this->assertTrue($view->filter['status']->value);
$this->assertEqual($view->filter['status_node']->table, 'node');
$this->assertEqual($view->filter['status_node']->field, 'status');
$this->assertTrue($view->filter['status_node']->value);
// Check for the default fields.
$this->assertEqual($view->field['subject']->table, 'comment');
$this->assertEqual($view->field['subject']->field, 'subject');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment