Unverified Commit 050b91b7 authored by larowlan's avatar larowlan
Browse files

Issue #3160405 by mondrake, ravi.shankar, jungle, longwave: Deprecate...

Issue #3160405 by mondrake, ravi.shankar, jungle, longwave: Deprecate overloading arguments to WebAssert methods to prevent conversions of legacy Simpletest test to carry over cruft
parent 82949679
......@@ -141,11 +141,15 @@ public function testMultipleClosingBodies_2678662() {
// Besides verifying there is no JavaScript syntax error, also verify the
// HTML structure.
// The BigPipe stop signal is present just before the closing </body> and
// </html> tags.
$this->assertSession()
->responseContains(BigPipe::STOP_SIGNAL . "\n\n\n</body></html>", 'The BigPipe stop signal is present just before the closing </body> and </html> tags.');
->responseContains(BigPipe::STOP_SIGNAL . "\n\n\n</body></html>");
$js_code_until_closing_body_tag = substr(BigPipeRegressionTestController::MARKER_2678662, 0, strpos(BigPipeRegressionTestController::MARKER_2678662, '</body>'));
// The BigPipe start signal does NOT start at the closing </body> tag string
// in an inline script.
$this->assertSession()
->responseNotContains($js_code_until_closing_body_tag . "\n" . BigPipe::START_SIGNAL, 'The BigPipe start signal does NOT start at the closing </body> tag string in an inline script.');
->responseNotContains($js_code_until_closing_body_tag . "\n" . BigPipe::START_SIGNAL);
}
/**
......
......@@ -175,7 +175,8 @@ public function testAnonymous() {
// NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');
// Attempt to view node-comment form while disallowed.
......@@ -199,7 +200,8 @@ public function testAnonymous() {
'skip comment approval' => TRUE,
]);
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');
......
......@@ -32,7 +32,7 @@ protected function setUp(): void {
// Make sure that comment field title is not displayed when there's no
// comments posted.
$this->drupalGet($this->node->toUrl());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments title is not displayed.');
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
// Set comments to have subject and preview disabled.
$this->setCommentPreview(DRUPAL_DISABLED);
......
......@@ -354,7 +354,8 @@ public function testCommentFunctionality() {
// Attempt to view comments while disallowed.
$this->drupalGet('entity-test/' . $this->entity->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');
// Attempt to view test entity comment form while disallowed.
......@@ -387,7 +388,8 @@ public function testCommentFunctionality() {
'view test entity' => TRUE,
]);
$this->drupalGet('entity_test/' . $this->entity->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');
......
......@@ -48,7 +48,7 @@ public function testCommentEmptyTitles() {
// Verify that the comment is created successfully.
$this->assertSession()->responseMatches($regex);
// Tests that markup is not generated for the comment without header.
$this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|', 'Comment title H3 element not found when title is an empty string.');
$this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|');
}
/**
......
......@@ -112,7 +112,7 @@ public function testNodeDisplay() {
$this->clickLink(t('Back to content editing'));
$this->assertRaw($field_name . '[0][display]', 'First file appears as expected.');
$this->assertRaw($field_name . '[1][display]', 'Second file appears as expected.');
$this->assertSession()->responseContains($field_name . '[1][description]', 'Description of second file appears as expected.');
$this->assertSession()->responseContains($field_name . '[1][description]');
// Check that the file fields don't contain duplicate HTML IDs.
$this->assertSession()->pageContainsNoDuplicateId();
......
......@@ -367,7 +367,7 @@ public function testImageFieldDefaultImage() {
$this->drupalGet('node/' . $node->id());
// Verify that no image is displayed on the page by checking for the class
// that would be used on the image field.
$this->assertSession()->responseNotMatches('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
$this->assertSession()->responseNotMatches('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">');
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
......
......@@ -157,12 +157,7 @@ public function testNodeAccessBasic() {
else {
$should_be_visible = TRUE;
}
$this->assertSession()->statusCodeEquals($should_be_visible ? 200 : 403, strtr('A %private node by user %uid is %visible for user %current_uid.', [
'%private' => $is_private ? 'private' : 'public',
'%uid' => $uid,
'%visible' => $should_be_visible ? 'visible' : 'not visible',
'%current_uid' => $this->webUser->id(),
]));
$this->assertSession()->statusCodeEquals($should_be_visible ? 200 : 403);
}
}
......
......@@ -414,7 +414,7 @@ public function testDuplicateNodeAlias() {
// This error should still be present next to the field.
$this->assertSession()->pageTextContains("The alias {$edit['path[0][alias]']} is already in use in this language.");
// The validation error set for the page should include this text.
$this->assertSession()->pageTextContains(t('1 error has been found: URL alias'), 'Form error found with expected text.');
$this->assertSession()->pageTextContains('1 error has been found: URL alias');
// The text 'URL alias' should be a link.
$this->assertSession()->linkExists('URL alias');
// The link should be to the ID of the URL alias field.
......
......@@ -105,13 +105,15 @@ public function testLogging() {
// Verify that logging scripts are not found on a non-node page.
$this->drupalGet('node');
$settings = $this->getDrupalSettings();
$this->assertSession()->responseNotMatches($expected_library, 'Statistics library JS not found on node page.');
// Statistics library JS should not be present.
$this->assertSession()->responseNotMatches($expected_library);
$this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.');
// Verify that logging scripts are not found on a non-existent node page.
$this->drupalGet('node/9999');
$settings = $this->getDrupalSettings();
$this->assertSession()->responseNotMatches($expected_library, 'Statistics library JS not found on non-existent node page.');
// Statistics library JS should not be present.
$this->assertSession()->responseNotMatches($expected_library);
$this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.');
// Verify that logging scripts are found on a valid node page.
......
......@@ -31,7 +31,7 @@ public function testMultipleTrue() {
$this->drupalGet('form_test/tableselect/multiple-true');
$this->assertSession()->responseNotContains('Empty text.', 'Empty text should not be displayed.');
$this->assertSession()->responseNotContains('Empty text.');
// Test for the presence of the Select all rows tableheader.
$this->assertNotEmpty($this->xpath('//th[@class="select-all"]'), 'Presence of the "Select all" checkbox.');
......@@ -65,8 +65,9 @@ public function testMultipleFalse() {
public function testTableSelectColSpan() {
$this->drupalGet('form_test/tableselect/colspan');
$this->assertSession()->pageTextContains('Three', 'Presence of the third column');
$this->assertSession()->pageTextNotContains('Four', 'Absence of a fourth column');
// Verify presence of column three and absence of column four.
$this->assertSession()->pageTextContains('Three');
$this->assertSession()->pageTextNotContains('Four');
// There should be three labeled column headers and 1 for the input.
$table_head = $this->xpath('//thead/tr/th');
......@@ -88,7 +89,7 @@ public function testTableSelectColSpan() {
*/
public function testEmptyText() {
$this->drupalGet('form_test/tableselect/empty-text');
$this->assertSession()->pageTextContains('Empty text.', 'Empty text should be displayed.');
$this->assertSession()->pageTextContains('Empty text.');
}
/**
......@@ -102,18 +103,18 @@ public function testMultipleTrueSubmit() {
$this->drupalPostForm('form_test/tableselect/multiple-true', $edit, 'Submit');
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Submitted: row1 = row1', 'Checked checkbox row1');
$assert_session->pageTextContains('Submitted: row2 = 0', 'Unchecked checkbox row2.');
$assert_session->pageTextContains('Submitted: row3 = 0', 'Unchecked checkbox row3.');
$assert_session->pageTextContains('Submitted: row1 = row1');
$assert_session->pageTextContains('Submitted: row2 = 0');
$assert_session->pageTextContains('Submitted: row3 = 0');
// Test a submission with multiple checkboxes checked.
$edit['tableselect[row1]'] = TRUE;
$edit['tableselect[row3]'] = TRUE;
$this->drupalPostForm('form_test/tableselect/multiple-true', $edit, 'Submit');
$assert_session->pageTextContains('Submitted: row1 = row1', 'Checked checkbox row1.');
$assert_session->pageTextContains('Submitted: row2 = 0', 'Unchecked checkbox row2.');
$assert_session->pageTextContains('Submitted: row3 = row3', 'Checked checkbox row3.');
$assert_session->pageTextContains('Submitted: row1 = row1');
$assert_session->pageTextContains('Submitted: row2 = 0');
$assert_session->pageTextContains('Submitted: row3 = row3');
}
......@@ -123,7 +124,7 @@ public function testMultipleTrueSubmit() {
public function testMultipleFalseSubmit() {
$edit['tableselect'] = 'row1';
$this->drupalPostForm('form_test/tableselect/multiple-false', $edit, 'Submit');
$this->assertSession()->pageTextContains('Submitted: row1', 'Selected radio button');
$this->assertSession()->pageTextContains('Submitted: row1');
}
/**
......
......@@ -66,7 +66,8 @@ public function testForm() {
$this->drupalPostForm(NULL, $edit, 'Save');
$assert_session->pageTextContains('Form constructions: 4');
$assert_session->pageTextContains('Title: new', 'The form storage has stored the values.');
// Verify that the form storage has stored the values.
$assert_session->pageTextContains('Title: new');
}
/**
......@@ -93,7 +94,8 @@ public function testFormCached() {
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertSession()->pageTextContains('Form constructions: 4');
$this->assertSession()->pageTextContains('Title: new', 'The form storage has stored the values.');
// Verify that the form storage has stored the values.
$this->assertSession()->pageTextContains('Title: new');
}
/**
......@@ -137,7 +139,7 @@ public function testCachedFormStorageValidation() {
// validation error. Post again and verify that the rebuilt form contains
// the values of the updated form storage.
$this->drupalPostForm(NULL, ['title' => 'foo', 'value' => 'bar'], 'Save');
$this->assertSession()->pageTextContains("The thing has been changed.", 'The altered form storage value was updated in cache and taken over.');
$this->assertSession()->pageTextContains("The thing has been changed.");
}
/**
......
......@@ -59,7 +59,7 @@ public function testFinishResponseSubscriber() {
$this->assertRaw('</html>', 'Page markup was found.');
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this->assertSession()->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
$this->assertSession()->responseNotMatches('#</body>.*</body>#s');
// Confirm that route-level access check's cacheability is applied to the
// X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags headers.
......@@ -156,7 +156,7 @@ public function testControllerPlaceholders() {
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this->assertSession()->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
$this->assertSession()->responseNotMatches('#</body>.*</body>#s');
}
/**
......@@ -173,7 +173,7 @@ public function testControllerPlaceholdersDefaultValues() {
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this->assertSession()->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
$this->assertSession()->responseNotMatches('#</body>.*</body>#s');
}
/**
......@@ -190,7 +190,7 @@ public function testControllerPlaceholdersDefaultValuesProvided() {
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this->assertSession()->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
$this->assertSession()->responseNotMatches('#</body>.*</body>#s');
}
/**
......@@ -219,7 +219,7 @@ public function testControllerResolutionPage() {
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this->assertSession()->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
$this->assertSession()->responseNotMatches('#</body>.*</body>#s');
}
/**
......
......@@ -109,7 +109,7 @@ public function testPreserveFormActionAfterAJAX() {
'title[0][value]' => $this->randomString(),
];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertSession()->pageTextContains('Test file field is required.', 'Non-AJAX submission correctly triggered a validation error.');
$this->assertSession()->pageTextContains('Test file field is required.');
// Ensure that the form contains two items in the multi-valued field, so we
// know we're testing a form that was correctly retrieved from cache.
......
......@@ -122,7 +122,7 @@ public function testLazyLoadOverriddenCSS() {
// information about the file; we only really care about whether it appears
// in a LINK or STYLE tag, for which Drupal always adds a query string for
// cache control.
$assert->responseNotContains('js.module.css?', 'Ajax lazy loading does not add overridden CSS files.');
$assert->responseNotContains('js.module.css?');
}
}
......@@ -56,7 +56,8 @@ public function testTaxonomyTermOverviewPager() {
// Get Page 1.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
$this->assertSession()->responseNotMatches('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1');
// Pager should not be visible.
$this->assertSession()->responseNotMatches('|<nav class="pager" [^>]*>|');
// Create 3 more terms to show pager.
for ($x = 1; $x <= 3; $x++) {
......
......@@ -140,7 +140,8 @@ protected function assertSecurityUpdates($project_path_part, array $expected_sec
if ($expected_update_message_type === static::SECURITY_UPDATE_REQUIRED) {
$assert_session->elementTextNotContains('css', $update_element_css_locator, 'Update available');
$assert_session->elementTextContains('css', $update_element_css_locator, 'Security update required!');
$assert_session->responseContains('error.svg', 'Error icon was found.');
// Verify that the error icon is found.
$assert_session->responseContains('error.svg');
}
else {
$assert_session->elementTextContains('css', $update_element_css_locator, 'Update available');
......
This diff is collapsed.
This diff is collapsed.
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