Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -31,7 +31,7 @@ class ViewsUIController extends ControllerBase {
/**
* Constructs a new \Drupal\views_ui\Controller\ViewsUIController object.
*
* @param \Drupal\views\ViewsData views_data
* @param \Drupal\views\ViewsData $views_data
* The Views data cache object.
*/
public function __construct(ViewsData $views_data) {

View file

@ -95,7 +95,7 @@ class AddHandler extends ViewsFormBase {
$groups = array('all' => $this->t('- All -'));
$form['override']['controls']['group'] = array(
'#type' => 'select',
'#title' => $this->t('Type'),
'#title' => $this->t('Category'),
'#options' => array(),
);

View file

@ -331,7 +331,7 @@ class RearrangeFilter extends ViewsFormBase {
*
* For example array(0 => 'foo') would be array(1 => 'foo').
*
* @param array
* @param array $array
* The array to increment keys on.
*
* @return array

View file

@ -115,7 +115,7 @@ class CustomBooleanTest extends UITestBase {
->save();
$this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme');
// Add the boolean field handler to the test view.
// Add the boolean field handler to the test view.
$view = Views::getView('test_view');
$view->setDisplay();

View file

@ -191,7 +191,7 @@ class DisplayTest extends UITestBase {
*/
public function testPageContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links')));
$view = entity_load('view', 'test_display');
$view = View::load('test_display');
$view->enable()->save();
$this->container->get('router.builder')->rebuildIfNeeded();

View file

@ -18,6 +18,20 @@ class ExposedFormUITest extends UITestBase {
*/
public static $testViews = array('test_exposed_admin_ui');
/**
* {@inheritdoc}
*/
public static $modules = array('node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime');
/**
* Array of error message strings raised by the grouped form.
*
* @var array
*
* @see FilterPluginBase::buildGroupValidate
*/
protected $groupFormUiErrors = [];
protected function setUp() {
parent::setUp();
@ -28,6 +42,11 @@ class ExposedFormUITest extends UITestBase {
for ($i = 0; $i < 5; $i++) {
$this->drupalCreateNode();
}
// Error strings used in the grouped filter form validation.
$this->groupFormUiErrors['missing_value'] = t('A value is required if the label for this item is defined.');
$this->groupFormUiErrors['missing_title'] = t('A label is required if the value for this item is defined.');
$this->groupFormUiErrors['missing_title_empty_operator'] = t('A label is required for the specified operator.');
}
/**
@ -51,8 +70,6 @@ class ExposedFormUITest extends UITestBase {
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
// Check the label of the expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
// Check the label of the grouped exposed button
$this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters'));
// After exposing the filter, Operator and Value should be still here.
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
@ -76,62 +93,6 @@ class ExposedFormUITest extends UITestBase {
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort'));
$this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown');
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
$this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists');
$this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists');
$this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
$this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
// Check that after click on 'Grouped Filters', a new button is shown to
// add more items to the list.
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
// Create a grouped filter
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$edit["options[group_info][group_items][2][title]"] = 'Is Page';
$edit["options[group_info][group_items][2][value][page]"] = TRUE;
$edit["options[group_info][group_items][3][title]"] = 'Is Page and Article';
$edit["options[group_info][group_items][3][value][article]"] = TRUE;
$edit["options[group_info][group_items][3][value][page]"] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Select the empty operator, so the empty value should not trigger a form
// error.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = $this->randomMachineName();
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'Validation did not run for the empty operator.');
// Test the validation error message text is not shown.
$this->assertNoText(t('The value is required if title for this item is defined.'));
// Validate that all the titles are defined for each group
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = TRUE;
// This should trigger an error
$edit["options[group_info][group_items][2][title]"] = '';
$edit["options[group_info][group_items][2][value][page]"] = TRUE;
$edit["options[group_info][group_items][3][title]"] = 'Is Page and Article';
$edit["options[group_info][group_items][3][value][article]"] = TRUE;
$edit["options[group_info][group_items][3][value][page]"] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertRaw(t('The title is required if value for this item is defined.'), 'Group items should have a title');
// Un-expose the filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm(NULL, array(), t('Hide filter'));
@ -170,4 +131,138 @@ class ExposedFormUITest extends UITestBase {
$this->assertEqual($display['display_options']['sorts']['created']['order'], 'DESC');
}
/**
* Tests the admin interface of exposed grouped filters.
*/
function testGroupedFilterAdminUi() {
$edit = array();
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
// Click the Expose filter button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
// Check the label of the grouped filters button.
$this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters'));
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
$this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists');
$this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists');
$this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
$this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
// Check that after click on 'Grouped Filters', a new button is shown to
// add more items to the list.
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
// Validate a single entry for a grouped filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default');
$this->assertNoGroupedFilterErrors();
// Validate multiple entries for grouped filters.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$edit["options[group_info][group_items][2][title]"] = 'Is Page';
$edit["options[group_info][group_items][2][value][page]"] = 'page';
$edit["options[group_info][group_items][3][title]"] = 'Is Page and Article';
$edit["options[group_info][group_items][3][value][article]"] = 'article';
$edit["options[group_info][group_items][3][value][page]"] = 'page';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'Correct validation of the node type filter.');
$this->assertNoGroupedFilterErrors();
// Validate an "is empty" filter -- title without value is valid.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'No body';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "empty" operator validates correctly.');
$this->assertNoGroupedFilterErrors();
// Ensure the string "0" can be used as a value for numeric filters.
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', array('name[node_field_data.nid]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
$this->drupalPostForm(NULL, array(), t('Expose filter'));
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
$edit = array();
$edit['options[group_info][group_items][1][title]'] = 'Testing zero';
$edit['options[group_info][group_items][1][operator]'] = '>';
$edit['options[group_info][group_items][1][value][value]'] = '0';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'A string "0" is a valid value.');
$this->assertNoGroupedFilterErrors();
// Ensure "between" filters validate correctly.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/nid');
$edit['options[group_info][group_items][1][title]'] = 'ID between test';
$edit['options[group_info][group_items][1][operator]'] = 'between';
$edit['options[group_info][group_items][1][value][min]'] = '0';
$edit['options[group_info][group_items][1][value][max]'] = '10';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "between" filter validates correctly.');
$this->assertNoGroupedFilterErrors();
}
public function testGroupedFilterAdminUiErrors() {
// Select the empty operator without a title specified.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_title_empty_operator']);
// Specify a title without a value.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
$edit = array();
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_value']);
// Specify a value without a title.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = array();
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_title']);
}
/**
* Asserts that there are no Grouped Filters errors.
*
* @param string $message
* The assert message.
* @param string $group
* The assertion group.
*
* @return bool
* Result of the assertion.
*/
protected function assertNoGroupedFilterErrors($message = '', $group = 'Other') {
foreach ($this->groupFormUiErrors as $error) {
$err_message = $message;
if (empty($err_message)) {
$err_message = "Verify that '$error' is not in the HTML output.";
}
if (empty($message)) {
return $this->assertNoRaw($error, $err_message, $group);
}
}
return TRUE;
}
}

View file

@ -3,6 +3,7 @@
namespace Drupal\views_ui\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
/**
* Tests the UI preview functionality.
@ -324,7 +325,7 @@ class PreviewTest extends UITestBase {
);
$url = $this->getAbsoluteUrl($url);
$post = array('js' => 'true') + $this->getAjaxPageStatePostData();
$result = Json::decode($this->drupalPost($url, 'application/vnd.drupal-ajax', $post));
$result = Json::decode($this->drupalPost($url, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]));
if (!empty($result)) {
$this->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings);
}

View file

@ -46,7 +46,7 @@ class ViewsListTest extends WebTestBase {
// Check if we can access the main views admin page.
$this->drupalGet('admin/structure/views');
$this->assertResponse(200);
$this->assertLink(t('Add new view'));
$this->assertLink(t('Add view'));
// Count default views to be subtracted from the limit.
$views = count(Views::getEnabledViews());

View file

@ -1160,9 +1160,9 @@ class ViewUI implements ViewEntityInterface {
/**
* {@inheritdoc}
*/
public function referencedEntities() {
return $this->storage->referencedEntities();
}
public function referencedEntities() {
return $this->storage->referencedEntities();
}
/**
* {@inheritdoc}

View file

@ -1,5 +1,5 @@
views_add_local_action:
route_name: views_ui.add
title: 'Add new view'
title: 'Add view'
appears_on:
- entity.view.collection

View file

@ -23,7 +23,7 @@ function views_ui_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing views') . '</dt>';
$output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add new view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
$output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
$output .= '<dt>' . t('Enabling and disabling views') . '<dt>';
$output .= '<dd>' . t('Views can be enabled or disabled from the <a href=":list">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
$output .= '<dt>' . t('Exporting and importing views') . '</dt>';

View file

@ -1,4 +1,3 @@
administer views:
title: 'Administer views'
description: 'Access the views administration pages.'
restrict access: true

View file

@ -10,7 +10,7 @@ views_ui.add:
path: '/admin/structure/views/add'
defaults:
_entity_form: 'view.add'
_title: 'Add new view'
_title: 'Add view'
requirements:
_entity_create_access: view