update drupal

This commit is contained in:
Tessier
2020-10-15 11:59:37 +02:00
parent ebb5db14b5
commit d8b9162932
558 changed files with 5954 additions and 4475 deletions
@@ -2,6 +2,7 @@
namespace Drupal\views_ui\Controller;
use Drupal\Component\Utility\Tags;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Link;
use Drupal\Core\Url;
@@ -188,13 +189,15 @@ class ViewsUIController extends ControllerBase {
// Keep track of previously processed tags so they can be skipped.
$tags = [];
foreach ($views as $view) {
$tag = $view->get('tag');
if ($tag && !in_array($tag, $tags)) {
$tags[] = $tag;
if (strpos($tag, $string) === 0) {
$matches[] = ['value' => $tag, 'label' => Html::escape($tag)];
if (count($matches) >= 10) {
break;
$view_tag = $view->get('tag');
foreach (Tags::explode($view_tag) as $tag) {
if ($tag && !in_array($tag, $tags, TRUE)) {
$tags[] = $tag;
if (mb_stripos($tag, $string) !== FALSE) {
$matches[] = ['value' => $tag, 'label' => Html::escape($tag)];
if (count($matches) >= 10) {
break 2;
}
}
}
}
@@ -9,7 +9,7 @@ use Drupal\views\Plugin\ViewsPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for the Views edit form.
* Form controller for the Views add form.
*
* @internal
*/
@@ -23,7 +23,7 @@ class ViewAddForm extends ViewFormBase {
protected $wizardManager;
/**
* Constructs a new ViewEditForm object.
* Constructs a new ViewAddForm object.
*
* @param \Drupal\views\Plugin\ViewsPluginManager $wizard_manager
* The wizard plugin manager.
@@ -47,7 +47,7 @@ class DefaultViewsTest extends UITestBase {
// Enable the view, and make sure it is now visible on the main listing
// page.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Enable'), '/glossary/');
$this->clickViewsOperationLink('Enable', '/glossary/');
$this->assertUrl('admin/structure/views');
$this->assertLinkByHref($edit_href);
@@ -76,7 +76,7 @@ class DefaultViewsTest extends UITestBase {
$this->drupalGet('admin/structure/views');
$this->assertLinkByHref('admin/structure/views/view/archive/enable');
// Enable it again so it can be tested for access permissions.
$this->clickViewsOperationLink(t('Enable'), '/archive/');
$this->clickViewsOperationLink('Enable', '/archive/');
// It should now be possible to revert the view. Do that, and make sure the
// view title we added above no longer is displayed.
@@ -89,7 +89,7 @@ class DefaultViewsTest extends UITestBase {
// Duplicate the view and check that the normal schema of duplicated views is used.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
$this->clickViewsOperationLink('Duplicate', '/glossary');
$edit = [
'id' => 'duplicate_of_glossary',
];
@@ -99,7 +99,7 @@ class DefaultViewsTest extends UITestBase {
// Duplicate a view and set a custom name.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
$this->clickViewsOperationLink('Duplicate', '/glossary');
$random_name = strtolower($this->randomMachineName());
$this->drupalPostForm(NULL, ['id' => $random_name], t('Duplicate'));
$this->assertUrl("admin/structure/views/view/$random_name", [], 'The custom view name got saved.');
@@ -109,13 +109,13 @@ class DefaultViewsTest extends UITestBase {
// listing page.
// @todo Test this behavior with templates instead.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Disable'), '/glossary/');
$this->clickViewsOperationLink('Disable', '/glossary/');
// $this->assertUrl('admin/structure/views');
// $this->assertNoLinkByHref($edit_href);
// The easiest way to verify it appears on the disabled views listing page
// is to try to click the "enable" link from there again.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Enable'), '/glossary/');
$this->clickViewsOperationLink('Enable', '/glossary/');
$this->assertUrl('admin/structure/views');
$this->assertLinkByHref($edit_href);
@@ -132,7 +132,7 @@ class DefaultViewsTest extends UITestBase {
// Test deleting a view.
$this->drupalLogin($this->fullAdminUser);
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), '/glossary/');
$this->clickViewsOperationLink('Delete', '/glossary/');
// Submit the confirmation form.
$this->drupalPostForm(NULL, [], t('Delete'));
// Ensure the view is no longer listed.
@@ -145,7 +145,7 @@ class DefaultViewsTest extends UITestBase {
// Delete all duplicated Glossary views.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
$this->clickViewsOperationLink('Delete', 'duplicate_of_glossary');
// Submit the confirmation form.
$this->drupalPostForm(NULL, [], t('Delete'));
@@ -153,7 +153,7 @@ class DefaultViewsTest extends UITestBase {
$this->assertSession()->statusCodeEquals(200);
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), $random_name);
$this->clickViewsOperationLink('Delete', $random_name);
// Submit the confirmation form.
$this->drupalPostForm(NULL, [], t('Delete'));
$this->drupalGet('glossary');
@@ -183,7 +183,7 @@ class DefaultViewsTest extends UITestBase {
$this->assertCount(1, $elements, 'A disabled view is found in the disabled views table.');
// Enable the view.
$this->clickViewsOperationLink(t('Enable'), '/test_view_status/');
$this->clickViewsOperationLink('Enable', '/test_view_status/');
$elements = $this->xpath($xpath, $arguments);
$this->assertCount(0, $elements, 'After enabling a view, it is not found in the disabled views table.');
@@ -69,7 +69,7 @@ class ExposedFormUITest extends UITestBase {
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
// Be sure that the button is called exposed.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter'));
$this->helperButtonHasLabel('edit-options-expose-button-button', 'Expose filter');
// The first time the filter UI is displayed, the operator and the
// value forms should be shown.
@@ -81,7 +81,7 @@ class ExposedFormUITest extends UITestBase {
// 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 expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
$this->helperButtonHasLabel('edit-options-expose-button-button', 'Hide filter');
// After exposing the filter, Operator and Value should be still here.
$this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists');
@@ -102,7 +102,7 @@ class ExposedFormUITest extends UITestBase {
// Now check the sort criteria.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created');
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort'));
$this->helperButtonHasLabel('edit-options-expose-button-button', 'Expose sort');
$this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown');
// Un-expose the filter.
@@ -119,7 +119,7 @@ class ExposedFormUITest extends UITestBase {
$edit = [];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
// Check the label of the expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
$this->helperButtonHasLabel('edit-options-expose-button-button', 'Hide sort');
$this->assertFieldById('edit-options-expose-label', 'Authored on', 'Make sure a label field is shown');
// Test adding a new exposed sort criteria.
@@ -154,7 +154,7 @@ class ExposedFormUITest extends UITestBase {
// 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'));
$this->helperButtonHasLabel('edit-options-group-button-button', 'Grouped filters');
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
@@ -169,7 +169,7 @@ class ExposedFormUITest extends UITestBase {
// 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'));
$this->helperButtonHasLabel('edit-options-group-info-add-group', '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');
@@ -32,6 +32,11 @@ class FilterBooleanWebTest extends UITestBase {
$result = $this->cssSelect('#edit-options-value--wrapper legend span');
$this->assertEqual($result[0]->getHtml(), 'Status');
// Ensure that the operator and the filter value are displayed using correct
// layout.
$this->assertSession()->elementExists('css', '.views-left-30 .form-item-options-operator');
$this->assertSession()->elementExists('css', '.views-right-70 .form-item-options-value');
$this->drupalPostForm(NULL, [], t('Expose filter'));
$this->drupalPostForm(NULL, [], t('Grouped filters'));
@@ -193,7 +193,7 @@ class OverrideDisplaysTest extends UITestBase {
// Revert the title of the block to the default ones, but submit some new
// values to be sure that the new value is not stored.
$edit = [];
$edit['title'] = $new_block_title = $this->randomMachineName();
$edit['title'] = $this->randomMachineName();
$edit['override[dropdown]'] = 'default_revert';
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply'));
@@ -22,7 +22,7 @@ class TagTest extends ViewsKernelTestBase {
public static $modules = ['views', 'views_ui', 'user'];
/**
* Tests the views_ui_autocomplete_tag function.
* Tests the ViewsUIController::autocompleteTag() function.
*/
public function testViewsUiAutocompleteTag() {
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
@@ -68,4 +68,41 @@ class TagTest extends ViewsKernelTestBase {
$this->assertCount(0, $matches, "Make sure an invalid tag doesn't return anything.");
}
/**
* Tests that comma delimited tags are treated as individual tags.
*
* @dataProvider providerViewsUiAutocompleteIndividualTags
*/
public function testViewsUiAutocompleteIndividualTags($expected_tag, $search_string) {
$controller = ViewsUIController::create($this->container);
$request = $this->container->get('request_stack')->getCurrentRequest();
$tag = 'comma, 你好, Foo bar';
View::create(['tag' => $tag, 'id' => $this->randomMachineName()])->save();
$request->query->set('q', $search_string);
$result = $controller->autocompleteTag($request);
$matches = (array) json_decode($result->getContent());
$this->assertCount(1, $matches);
$this->assertSame($expected_tag, $matches[0]->value);
}
/**
* Data provider for testViewsUiAutocompleteIndividualTags().
*
* @return array[]
* The data set.
*/
public function providerViewsUiAutocompleteIndividualTags() {
return [
'tag' => ['comma', 'comma'],
'case insensitive tag' => ['comma', 'COMMA'],
'Hello in Chinese (partial 1)' => ['你好', '你'],
'Hello in Chinese (partial 2)' => ['你好', '好'],
'Hello in Chinese' => ['你好', '你好'],
'Starts with partial and case-sensitive' => ['Foo bar', 'Foo'],
'Starts with partial and case-insensitive' => ['Foo bar', 'fOO'],
'Ends with partial and case-sensitive' => ['Foo bar', 'bar'],
'Ends with partial and case-insensitive' => ['Foo bar', 'BAR'],
];
}
}