diff -u b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php --- b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php @@ -64,7 +64,7 @@ $this->drupalPostForm('admin/structure/views/view/test_view/edit', [], t('Save')); $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view'])); - // Test that a deleted view has no 4tempstore data. + // Test that a deleted view has no tempstore data. $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply')); $this->drupalPostForm('admin/structure/views/view/test_view/delete', [], t('Delete')); // No view tempstore data should be returned for this view after deletion. diff -u b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php --- b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php @@ -41,7 +41,7 @@ // Enable the view, and make sure it is now visible on the main listing // page. $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Enable', '/glossary/'); + $this->clickViewsOperationLink(t('Enable'), '/glossary/'); $this->assertUrl('admin/structure/views'); $this->assertLinkByHref($edit_href); @@ -70,7 +70,7 @@ $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('Enable', '/archive/'); + $this->clickViewsOperationLink(t('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. @@ -83,7 +83,7 @@ // Duplicate the view and check that the normal schema of duplicated views is used. $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Duplicate', '/glossary'); + $this->clickViewsOperationLink(t('Duplicate'), '/glossary'); $edit = [ 'id' => 'duplicate_of_glossary', ]; @@ -93,7 +93,7 @@ // Duplicate a view and set a custom name. $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Duplicate', '/glossary'); + $this->clickViewsOperationLink(t('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.'); @@ -103,13 +103,13 @@ // listing page. // @todo Test this behavior with templates instead. $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Disable', '/glossary/'); + $this->clickViewsOperationLink(t('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('Enable', '/glossary/'); + $this->clickViewsOperationLink(t('Enable'), '/glossary/'); $this->assertUrl('admin/structure/views'); $this->assertLinkByHref($edit_href); @@ -126,7 +126,7 @@ // Test deleting a view. $this->drupalLogin($this->fullAdminUser); $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Delete', '/glossary/'); + $this->clickViewsOperationLink(t('Delete'), '/glossary/'); // Submit the confirmation form. $this->drupalPostForm(NULL, [], t('Delete')); // Ensure the view is no longer listed. @@ -139,7 +139,7 @@ // Delete all duplicated Glossary views. $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Delete', 'duplicate_of_glossary'); + $this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary'); // Submit the confirmation form. $this->drupalPostForm(NULL, [], t('Delete')); @@ -147,7 +147,7 @@ $this->assertResponse(200); $this->drupalGet('admin/structure/views'); - $this->clickViewsOperationLink('Delete', $random_name); + $this->clickViewsOperationLink(t('Delete'), $random_name); // Submit the confirmation form. $this->drupalPostForm(NULL, [], t('Delete')); $this->drupalGet('glossary'); @@ -177,7 +177,7 @@ $this->assertIdentical(count($elements), 1, 'A disabled view is found in the disabled views table.'); // Enable the view. - $this->clickViewsOperationLink('Enable', '/test_view_status/'); + $this->clickViewsOperationLink(t('Enable'), '/test_view_status/'); $elements = $this->xpath($xpath, $arguments); $this->assertIdentical(count($elements), 0, 'After enabling a view, it is not found in the disabled views table.'); @@ -227,7 +227,7 @@ * failure. Failure also results in a failed assertion. */ public function clickViewsOperationLink($label, $unique_href_part) { - $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]); + $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => (string) $label]); foreach ($links as $link_index => $link) { $position = strpos($link->getAttribute('href'), $unique_href_part); if ($position !== FALSE) { @@ -237,7 +237,7 @@ } $this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', ['@label' => $label, '@part' => $unique_href_part])); if (isset($index)) { - return $this->clickLink($label, $index); + return $this->clickLink((string) $label, $index); } else { return FALSE; diff -u b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php --- b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -164,8 +164,8 @@ unset($menu_options['@attributes']); // Convert array to make the next assertion possible. - $menu_options = array_map(function($Element) { - return $Element->getText(); + $menu_options = array_map(function($element) { + return $element->getText(); }, $menu_options); $this->assertEqual([ diff -u b/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php --- b/core/modules/views_ui/tests/src/Functional/DisplayTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php @@ -88,11 +88,6 @@ $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.'); $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.'); $this->drupalPostForm(NULL, [], 'Disable Page'); - - // Reset cache to apply the changes above and reload the page. - $this->resetAll(); - $this->drupalGet($path_prefix); - $this->assertTrue($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.'); $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.'); @@ -197,9 +192,6 @@ $view = Views::getView($id); $view->storage->disable()->save(); - // Reset cache to apply the changes above. - $this->resetAll(); - $this->drupalGet('admin/structure/views/view/' . $id); $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'disabled']); $this->assertTrue($elements, 'The disabled class was found on the form wrapper.'); @@ -219,9 +211,6 @@ $display['display_title'] = $input; $view->save(); - // Reset cache to apply the changes above. - $this->resetAll(); - $this->drupalGet("admin/structure/views/view/{$view->id()}"); $escaped = views_ui_truncate($input, 25); $this->assertEscaped($escaped); @@ -285,10 +274,6 @@ // Test that the override option is shown when display master is on. \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', TRUE)->save(); - - // Reset cache to apply the changes above. - $this->resetAll(); - $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title'); $this->assertText('All displays'); @@ -296,10 +281,6 @@ // overridden so that the option to revert is available. $this->drupalPostForm(NULL, ['override[dropdown]' => 'page_1'], t('Apply')); \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', FALSE)->save(); - - // Reset cache to apply the changes above. - $this->resetAll(); - $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title'); $this->assertText('Revert to default'); } diff -u b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php --- b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -295,17 +295,21 @@ // Select 'Grouped filters' radio button. $this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status', [], t('Grouped filters')); // Add 3 groupings. - $edit = [ - 'options[group_button][radios][radios]' => 1, - 'options[group_info][group_items][1][title]' => 'Any', - 'options[group_info][group_items][1][value]' => 'All', - 'options[group_info][group_items][2][title]' => 'Published', - 'options[group_info][group_items][2][value]' => 1, - 'options[group_info][group_items][3][title]' => 'Unpublished', - 'options[group_info][group_items][3][value]' => 0, - ]; + + $page = $this->getSession()->getPage(); + $page->findField('options[group_button][radios][radios]')->selectOption(1); + $page->findField('options[group_info][group_items][1][title]')->setValue('All'); + $page->findField('options[group_info][group_items][1][value]')->selectOption('All'); + $page->findField('options[group_info][group_items][2][title]')->setValue('Published'); + $page->findField('options[group_info][group_items][2][value]')->selectOption('1'); + $page->findField('options[group_info][group_items][3][title]')->setValue('Unpublished'); + $page->findField('options[group_info][group_items][3][value]')->selectOption('0'); + + $this->assertTrue($page->find('css', '#edit-options-group-info-group-items-1-value-all')->isSelected()); + + // Apply the filter settings. - $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->drupalPostForm(NULL, [], t('Apply')); // Check that the view is saved without errors. $this->drupalPostForm(NULL, [], t('Save')); $this->assertResponse(200); reverted: --- b/core/modules/views_ui/tests/src/Functional/UITestBase.php +++ a/core/modules/views_ui/src/Tests/UITestBase.php @@ -1,8 +1,8 @@ enableViewsTestModule(); @@ -78,9 +78,9 @@ // Ensure that each nojs page is accessible via ajax as well. if (strpos($url, 'nojs') !== FALSE) { $url = str_replace('nojs', 'ajax', $url); + $result = $this->drupalGet($url, $options, $headers); + $this->assertResponse(200); + $this->assertHeader('Content-Type', 'application/json'); - $result = $this->drupalGet($url, $options); - $this->assertSession()->statusCodeEquals(200); - $this->assertEquals('application/json', $this->getSession()->getResponseHeader('Content-Type')); $this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.'); } only in patch2: unchanged: --- /dev/null +++ b/core/modules/views_ui/tests/src/Functional/UITestBase.php @@ -0,0 +1,90 @@ +enableViewsTestModule(); + + $this->adminUser = $this->drupalCreateUser(['administer views']); + + $this->fullAdminUser = $this->drupalCreateUser(['administer views', + 'administer blocks', + 'bypass node access', + 'access user profiles', + 'view all revisions', + 'administer permissions', + ]); + $this->drupalLogin($this->fullAdminUser); + } + + /** + * A helper method which creates a random view. + */ + public function randomView(array $view = []) { + // Create a new view in the UI. + $default = []; + $default['label'] = $this->randomMachineName(16); + $default['id'] = strtolower($this->randomMachineName(16)); + $default['description'] = $this->randomMachineName(16); + $default['page[create]'] = TRUE; + $default['page[path]'] = $default['id']; + + $view += $default; + + $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); + + return $default; + } + + /** + * {@inheritdoc} + */ + protected function drupalGet($path, array $options = [], array $headers = []) { + $url = $this->buildUrl($path, $options); + + // Ensure that each nojs page is accessible via ajax as well. + if (strpos($url, 'nojs') !== FALSE) { + $url = str_replace('nojs', 'ajax', $url); + $result = $this->drupalGet($url, $options); + $this->assertSession()->statusCodeEquals(200); + $this->assertEquals('application/json', $this->getSession()->getResponseHeader('Content-Type')); + $this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.'); + } + + return parent::drupalGet($path, $options, $headers); + } + +}