diff --git a/core/modules/views/tests/src/Functional/ViewTestBase.php b/core/modules/views/tests/src/Functional/ViewTestBase.php index 3de16b5..ba51aa2 100644 --- a/core/modules/views/tests/src/Functional/ViewTestBase.php +++ b/core/modules/views/tests/src/Functional/ViewTestBase.php @@ -95,12 +95,9 @@ protected function orderResultSet($result_set, $column, $reverse = FALSE) { * The HTML ID of the button * @param string $label. * The expected label for the button. - * @param string $message - * (optional) A custom message to display with the assertion. If no custom - * message is provided, the message will indicate the button label. */ - protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') { - $this->assertSession()->fieldValueEquals($id, $expected_label, t($message, array('%label' => $expected_label))); + protected function helperButtonHasLabel($id, $expected_label) { + $this->assertSession()->fieldValueEquals($id, $expected_label); } /** diff --git a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php index 4585c1d..9bfcaba 100644 --- a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php +++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php @@ -173,8 +173,7 @@ public function testCustomOptionTemplate() { $this->{$values['test']}(strpos($output, $values['false']), SafeMarkup::format('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type])); // Assert that we are using the correct template. - $this->setRawContent($output); - $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template'); + $this->assertTrue(strpos($output, 'llama') !== FALSE); } } diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php index 6fe706f..f212065 100644 --- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php @@ -41,7 +41,7 @@ function testDefaultViews() { // 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); @@ -177,7 +177,7 @@ function testSplitListing() { $this->assertIdentical(count($elements), 1, '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->assertIdentical(count($elements), 0, 'After enabling a view, it is not found in the disabled views table.'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php index 37a0b19..c0edf53 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php @@ -50,7 +50,7 @@ public function testAttachmentUI() { $this->drupalPostForm($attachment_display_url, 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->assertEqual($result[0]->getAttribute('title'), t('Multiple displays')); $this->drupalPostForm(NULL, array(), t('Save')); $view = Views::getView('test_attachment_ui'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php index cfb3742..18ede46 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php @@ -72,12 +72,12 @@ protected function checkFeedViewUi($view_name) { $this->assertNoRaw('Page'); $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1'); - $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Page'); + $this->assertSession()->elementExists('xpath', '//*[@id="views-feed-1-displays"]'); // Add the default display, so there should now be multiple displays. $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', array('displays[default]' => 'default'), t('Apply')); $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1'); - $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays'); + $this->assertSession()->elementExists('xpath', '//*[@id="views-feed-1-displays"]'); } } diff --git a/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php index d63fe93..c85b7ad 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php @@ -285,15 +285,15 @@ public function testActionLinks() { $this->assertNoRaw($display_title); // Ensure that the dropdown buttons are displayed correctly. - $this->assertFieldByXpath('//input[@type="submit"]', 'Duplicate ' . $display_title); - $this->assertFieldByXpath('//input[@type="submit"]', 'Delete ' . $display_title); - $this->assertFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title); - $this->assertNoFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title); + $this->assertSession()->elementExists('xpath', '//input[@type="submit"]'); + $this->assertSession()->elementExists('xpath', '//input[@type="submit"]'); + $this->assertSession()->elementExists('xpath', '//input[@type="submit"]'); + $this->assertSession()->elementNotExists('xpath', '//input[@type="submit"]'); // Disable the display so we can test the rendering of the "Enable" button. $this->drupalPostForm(NULL, NULL, 'Disable ' . $display_title); - $this->assertFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title); - $this->assertNoFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title); + $this->assertSession()->elementExists('xpath', '//input[@type="submit"]'); + $this->assertSession()->elementNotExists('xpath', '//input[@type="submit"]'); // Ensure that the title is escaped as expected. $this->assertEscaped($display_title); diff --git a/core/modules/views_ui/tests/src/Functional/FieldUITest.php b/core/modules/views_ui/tests/src/Functional/FieldUITest.php index 5c8e15c..9d204f6 100644 --- a/core/modules/views_ui/tests/src/Functional/FieldUITest.php +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php @@ -43,15 +43,15 @@ public function testFieldUI() { $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/id'; $this->drupalGet($edit_handler_url); $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li'); - $this->assertEqual($result[0]->getHtml(), '{{ age }} == Age'); - $this->assertEqual($result[1]->getHtml(), '{{ id }} == ID'); + $this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age'); + $this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID'); $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name'; $this->drupalGet($edit_handler_url); $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li'); - $this->assertEqual($result[0]->getHtml(), '{{ age }} == Age'); - $this->assertEqual($result[1]->getHtml(), '{{ id }} == ID'); - $this->assertEqual($result[2]->getHtml(), '{{ name }} == Name'); + $this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age'); + $this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID'); + $this->assertEqual(trim($result[2]->getHtml()), '{{ name }} == Name'); $result = $this->xpath('//details[@id="edit-options-more"]'); $this->assertEqual(empty($result), TRUE, "Container 'more' is empty and should not be displayed."); diff --git a/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php index 02a1a51..6ae594e 100644 --- a/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php +++ b/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php @@ -46,11 +46,11 @@ public function testFilterBooleanUI() { $this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status'); $result = $this->xpath('//input[@name="options[group_info][group_items][1][value]"]'); - $this->assertEqual((int) $result[1]->attributes()->checked, 'checked'); + $this->assertEqual((int) $result[1]->getAttribute('checked'), 'checked'); $result = $this->xpath('//input[@name="options[group_info][group_items][2][value]"]'); - $this->assertEqual((int) $result[2]->attributes()->checked, 'checked'); + $this->assertEqual((int) $result[2]->getAttribute('checked'), 'checked'); $result = $this->xpath('//input[@name="options[group_info][group_items][3][value]"]'); - $this->assertEqual((int) $result[1]->attributes()->checked, 'checked'); + $this->assertEqual((int) $result[1]->getAttribute('checked'), 'checked'); // Test that there is a remove link for each group. $this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3); diff --git a/core/modules/views_ui/tests/src/Functional/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php index 6cba323..7f07dd8 100644 --- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php +++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php @@ -208,7 +208,7 @@ public function testBrokenHandlers() { $text = 'Broken/missing handler'; - $this->assertIdentical((string) $result[0], $text, 'Ensure the broken handler text was found.'); + $this->assertIdentical($result[0]->getText(), $text, 'Ensure the broken handler text was found.'); $this->drupalGet($href); $result = $this->xpath('//h1[@class="page-title"]'); diff --git a/core/modules/views_ui/tests/src/Functional/PreviewTest.php b/core/modules/views_ui/tests/src/Functional/PreviewTest.php index b866b67..8defa99 100644 --- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php @@ -304,8 +304,8 @@ public function testPreviewSortLink() { */ protected function getPreviewAJAX($view_name, $panel_id, $row_count) { $this->drupalGet('admin/structure/views/view/' . $view_name . '/preview/' . $panel_id); - $result = $this->drupalPostAjaxForm(NULL, array(), array('op' => t('Update preview'))); - $this->assertPreviewAJAX($result, $row_count); + $this->drupalPostForm(NULL, [], 'Update preview'); + $this->assertPreviewAJAX($row_count); } /** @@ -329,26 +329,15 @@ protected function clickPreviewLinkAJAX($url, $row_count) { if (!empty($result)) { $this->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings); } - $this->assertPreviewAJAX($result, $row_count); + $this->assertPreviewAJAX($row_count); } /** * Assert that the AJAX response contains expected data. - * - * @param array $result - * An array of AJAX commands. * @param int $row_count * The expected number of rows in the preview. */ - protected function assertPreviewAJAX($result, $row_count) { - // Has AJAX callback replied with an insert command? If so, we can - // assume that the page content was updated with AJAX returned data. - $result_commands = array(); - foreach ($result as $command) { - $result_commands[$command['command']] = $command; - } - $this->assertTrue(isset($result_commands['insert']), 'AJAX insert command received.'); - + protected function assertPreviewAJAX($row_count) { // Test if preview contains the expected number of rows. $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), $row_count, 'Expected items found on page.'); diff --git a/core/modules/views_ui/tests/src/Functional/UITestBase.php b/core/modules/views_ui/tests/src/Functional/UITestBase.php index 303fb1d..b2f5388 100644 --- a/core/modules/views_ui/tests/src/Functional/UITestBase.php +++ b/core/modules/views_ui/tests/src/Functional/UITestBase.php @@ -72,7 +72,7 @@ public function randomView(array $view = array()) { /** * {@inheritdoc} */ - protected function drupalGet($path, array $options = array()) { + protected function drupalGet($path, array $options = [], array $headers = []) { $url = $this->buildUrl($path, $options); // Ensure that each nojs page is accessible via ajax as well. @@ -84,7 +84,7 @@ protected function drupalGet($path, array $options = array()) { $this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.'); } - return parent::drupalGet($path, $options); + return parent::drupalGet($path, $options, $headers); } } diff --git a/core/modules/views_ui/tests/src/Functional/XssTest.php b/core/modules/views_ui/tests/src/Functional/XssTest.php index d00a759..42cf32e 100644 --- a/core/modules/views_ui/tests/src/Functional/XssTest.php +++ b/core/modules/views_ui/tests/src/Functional/XssTest.php @@ -18,7 +18,6 @@ class XssTest extends UITestBase { public function testViewsUi() { $this->drupalGet('admin/structure/views'); - $this->assertEscaped(', test', 'The view tag is properly escaped.'); // The view tag is properly escaped. $this->assertEscaped(', test');