diff --git a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php index 8534051a8eb7eca80c6a872ef38f0fa9dbbf3df2..a4641d71f1537779a0b3e9030a6015e4fbbcb798 100644 --- a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +++ b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php @@ -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); } /** diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php index 15132da9c0771420c1bcac6acd581fd2eb467b88..8b1a7e46d3ec31b859d7a3408632e3a6453e2566 100644 --- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php @@ -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.'); diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index 4998f43d4687ebd51c98e945768586b76099cd04..a9001e8d4058386dd880ddf81582655dd3154c4a 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -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); diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index 84c3a6a889b8a0d05e8792963ed18f1899cb0db6..f0fbe3bd8a8848b5e7e3ae2ee3a257e22497f05c 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -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.'); diff --git a/core/modules/comment/tests/src/Functional/CommentTitleTest.php b/core/modules/comment/tests/src/Functional/CommentTitleTest.php index 3ac9d27c7b18da0098fc9e24e893f8cc92b5c051..d276e515070b46737a9e39bc83d3c13f85c5bfde 100644 --- a/core/modules/comment/tests/src/Functional/CommentTitleTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTitleTest.php @@ -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>|'); } /** diff --git a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php index 72d150e70f64aa317e617662f1bf7c7e5a208e33..7b3a92e8c547fe3b2a165519fabb9abb30ba5aca 100644 --- a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php @@ -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(); diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index 3e313ce5b6755023b9fdd562e1573f3aa9d84680..b1bcfdf0fc9b6c327fb0440d34dabc83e9f226df 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -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.'); diff --git a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php index 5401053852173f07b8dd3f35ad9079a0176aa0c9..ca9c1c814b8f93bd0668486e86ac220c5d45ea3d 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php @@ -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); } } diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php index 3d998ad3a93b090c8fcc92151006f2f7111ef7ef..5f233f1d0a261787fffea63c318d93bd0426bd34 100644 --- a/core/modules/path/tests/src/Functional/PathAliasTest.php +++ b/core/modules/path/tests/src/Functional/PathAliasTest.php @@ -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. diff --git a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php index f6083c89156a2cade9bcdd8a9ddc60387b71847f..f0f660e9e2a6460ad7c24ede72621b811af76779 100644 --- a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php +++ b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php @@ -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. diff --git a/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php b/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php index 91f7b2863cc33371b5250c8cc0e120cb66058435..ce0f3d84ea0a103407818eaf870bc354813cc9b1 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php @@ -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'); } /** diff --git a/core/modules/system/tests/src/Functional/Form/StorageTest.php b/core/modules/system/tests/src/Functional/Form/StorageTest.php index cb6c469f343c61543135b6fe1b969fe6be24141a..1005fd46f9dc664017ece76822bb79ab1c20adb5 100644 --- a/core/modules/system/tests/src/Functional/Form/StorageTest.php +++ b/core/modules/system/tests/src/Functional/Form/StorageTest.php @@ -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."); } /** diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index 16a83898871449c7ef7da35d06d155bb6495a7d4..b8ac3cadc0293798ab7197c557dd21b65d79ccbe 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -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'); } /** diff --git a/core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php b/core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php index fef51c7c00d220e0b61660d6c40485aa3912e087..d1365b898e4b552d4b29cf0e175b2c6059553b66 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php @@ -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. diff --git a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php index 8e1d576ca1c619f51717714716ee0c3f8165e7ed..3b12707f1b1415c4e607ec47b7c784059fbedc0a 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php @@ -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?'); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php index 5d380d1f12e6d94ee3491dbcd8d6d89197516900..5233169832b26a10bf8ea5faea9620cf5d9725f7 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php @@ -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++) { diff --git a/core/modules/update/tests/src/Functional/UpdateTestBase.php b/core/modules/update/tests/src/Functional/UpdateTestBase.php index 80f5b2496c3aa6873188d65d44dd803f85085433..7fa4206cc5c03fa34bd13eca9ce605b9646511da 100644 --- a/core/modules/update/tests/src/Functional/UpdateTestBase.php +++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php @@ -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'); diff --git a/core/tests/Drupal/Tests/Core/Assert/WebAssertArgumentsTest.php b/core/tests/Drupal/Tests/Core/Assert/WebAssertArgumentsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8149b0a9ee3f708b399dd40e1714c8e0c9e2a178 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Assert/WebAssertArgumentsTest.php @@ -0,0 +1,574 @@ +<?php + +namespace Drupal\Tests\Core\Assert; + +use Behat\Mink\Element\DocumentElement; +use Behat\Mink\Element\Element; +use Behat\Mink\Element\NodeElement; +use Behat\Mink\Session; +use Drupal\Tests\UnitTestCase; +use Drupal\Tests\WebAssert; +use Prophecy\Argument; + +/** + * Tests that calling WebAssert methods with extra arguments leads to errors. + * + * NOTE: Do not drop this test class in Drupal 10, convert the tests to check + * that \InvalidArgumentException are thrown instead of deprecations. + * + * @coversDefaultClass \Drupal\Tests\WebAssert + * @group Assert + * @group legacy + */ +class WebAssertArgumentsTest extends UnitTestCase { + + /** + * The mocked Mink session object used for testing. + * + * @var \Behat\Mink\Session|\Prophecy\Prophecy\ObjectProphecy + */ + protected $session; + + /** + * The mocked page element used for testing. + * + * @var Behat\Mink\Element\DocumentElement|\Prophecy\Prophecy\ObjectProphecy + */ + protected $page; + + /** + * The mocked web assert class. + * + * @var \Drupal\Tests\WebAssert + */ + protected $webAssert; + + /** + * {@inheritdoc} + */ + public function setUp(): void { + parent::setUp(); + + $this->page = $this->prophesize(DocumentElement::class); + $this->session = $this->prophesize(Session::class); + $this->session->getPage()->willReturn($this->page->reveal()); + $this->webAssert = new WebAssert($this->getSession()); + } + + /** + * @covers ::buttonExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::buttonExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testButtonExists(): void { + $this->page->findButton(Argument::any())->willReturn('bar'); + $this->webAssert->buttonExists('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::buttonNotExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::buttonNotExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testButtonNotExists(): void { + $this->page->findButton(Argument::any())->willReturn(NULL); + $this->webAssert->buttonNotExists('qux', NULL, 'Extra argument'); + } + + /** + * @covers ::selectExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::selectExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testSelectExists(): void { + $this->page->find(Argument::any(), Argument::any())->willReturn('bar'); + $this->webAssert->selectExists('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::optionExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::optionExists with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testOptionExists(): void { + $select = $this->prophesize(Element::class); + $select->find(Argument::any(), Argument::any())->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($select->reveal()); + $this->webAssert->optionExists('foo', 'bar', NULL, 'Extra argument'); + } + + /** + * @covers ::optionNotExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::optionNotExists with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testOptionNotExists(): void { + $select = $this->prophesize(Element::class); + $select->find(Argument::any(), Argument::any())->willReturn(NULL); + $this->page->find(Argument::any(), Argument::any())->willReturn($select->reveal()); + $this->webAssert->optionNotExists('foo', 'qux', NULL, 'Extra argument'); + } + + /** + * @covers ::titleEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::titleEquals with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testTitleEquals(): void { + $title = $this->prophesize(Element::class); + $title->getText()->willReturn('foo'); + $this->page->find(Argument::any(), Argument::any())->willReturn($title->reveal()); + $this->webAssert->titleEquals('foo', 'Extra argument'); + } + + /** + * @covers ::assertNoEscaped + * @expectedDeprecation Calling Drupal\Tests\WebAssert::assertNoEscaped with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testAssertNoEscaped(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->assertNoEscaped('qux', 'Extra argument'); + } + + /** + * @covers ::assertEscaped + * @expectedDeprecation Calling Drupal\Tests\WebAssert::assertEscaped with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testAssertEscaped(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->assertEscaped('foo', 'Extra argument'); + } + + /** + * @covers ::responseContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseContains with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseContains(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->responseContains('foo', 'Extra argument'); + } + + /** + * @covers ::responseNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseNotContains with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseNotContains(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->responseNotContains('qux', 'Extra argument'); + } + + /** + * @covers ::fieldDisabled + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldDisabled with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldDisabled(): void { + $field = $this->prophesize(NodeElement::class); + $field->hasAttribute('disabled')->willReturn(TRUE); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->fieldDisabled('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::fieldEnabled + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldEnabled with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldEnabled(): void { + $field = $this->prophesize(NodeElement::class); + $field->hasAttribute('disabled')->willReturn(FALSE); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->fieldEnabled('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::hiddenFieldExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::hiddenFieldExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testHiddenFieldExists(): void { + $this->page->find(Argument::any(), Argument::any())->willReturn('bar'); + $this->webAssert->hiddenFieldExists('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::hiddenFieldNotExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::hiddenFieldNotExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testHiddenFieldNotExists(): void { + $this->page->find(Argument::any(), Argument::any())->willReturn(NULL); + $this->webAssert->hiddenFieldNotExists('qux', NULL, 'Extra argument'); + } + + /** + * @covers ::hiddenFieldValueEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::hiddenFieldValueEquals with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testHiddenFieldValueEquals(): void { + $field = $this->prophesize(NodeElement::class); + $field->getValue()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($field->reveal()); + $this->webAssert->hiddenFieldValueEquals('foo', 'bar', NULL, 'Extra argument'); + } + + /** + * @covers ::hiddenFieldValueNotEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::hiddenFieldValueNotEquals with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testHiddenFieldValueNotEquals(): void { + $field = $this->prophesize(NodeElement::class); + $field->getValue()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($field->reveal()); + $this->webAssert->hiddenFieldValueNotEquals('foo', 'qux', NULL, 'Extra argument'); + } + + /** + * @covers ::pageTextContainsOnce + * @expectedDeprecation Calling Drupal\Tests\WebAssert::pageTextContainsOnce with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testPageTextContainsOnce(): void { + $this->page->getText()->willReturn('foo bar bar'); + $this->webAssert->pageTextContainsOnce('foo', 'Extra argument'); + } + + /** + * @covers ::addressEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::addressEquals with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testAddressEquals(): void { + $this->session->getCurrentUrl()->willReturn('foo'); + $this->webAssert->addressEquals('foo', 'Extra argument'); + } + + /** + * @covers ::addressNotEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::addressNotEquals with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testAddressNotEquals(): void { + $this->session->getCurrentUrl()->willReturn('foo'); + $this->webAssert->addressNotEquals('qux', 'Extra argument'); + } + + /** + * @covers ::addressMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::addressMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testAddressMatches(): void { + $this->session->getCurrentUrl()->willReturn('foo'); + $this->webAssert->addressMatches('/foo/', 'Extra argument'); + } + + /** + * @covers ::cookieEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::cookieEquals with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testCookieEquals(): void { + $this->session->getCookie('foo')->willReturn('bar'); + $this->webAssert->cookieEquals('foo', 'bar', 'Extra argument'); + } + + /** + * @covers ::cookieExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::cookieExists with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testCookieExists(): void { + $this->session->getCookie('foo')->willReturn('bar'); + $this->webAssert->cookieExists('foo', 'Extra argument'); + } + + /** + * @covers ::statusCodeEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::statusCodeEquals with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testStatusCodeEquals(): void { + $this->session->getStatusCode()->willReturn(200); + $this->webAssert->statusCodeEquals(200, 'Extra argument'); + } + + /** + * @covers ::statusCodeNotEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::statusCodeNotEquals with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testStatusCodeNotEquals(): void { + $this->session->getStatusCode()->willReturn(200); + $this->webAssert->statusCodeNotEquals(403, 'Extra argument'); + } + + /** + * @covers ::responseHeaderEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderEquals with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderEquals(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderEquals('foo', 'bar', 'Extra argument'); + } + + /** + * @covers ::responseHeaderNotEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderNotEquals with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderNotEquals(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderNotEquals('foo', 'qux', 'Extra argument'); + } + + /** + * @covers ::responseHeaderContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderContains with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderContains(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderContains('foo', 'ar', 'Extra argument'); + } + + /** + * @covers ::responseHeaderNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderNotContains with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderNotContains(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderNotContains('foo', 'qu', 'Extra argument'); + } + + /** + * @covers ::responseHeaderMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderMatches with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderMatches(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderMatches('foo', '/bar/', 'Extra argument'); + } + + /** + * @covers ::responseHeaderNotMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseHeaderNotMatches with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseHeaderNotMatches(): void { + $this->session->getResponseHeader('foo')->willReturn('bar'); + $this->webAssert->responseHeaderNotMatches('foo', '/qux/', 'Extra argument'); + } + + /** + * @covers ::pageTextContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::pageTextContains with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testPageTextContains(): void { + $this->page->getText()->willReturn('foo bar bar'); + $this->webAssert->pageTextContains('foo', 'Extra argument'); + } + + /** + * @covers ::pageTextNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::pageTextNotContains with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testPageTextNotContains(): void { + $this->page->getText()->willReturn('foo bar bar'); + $this->webAssert->pageTextNotContains('qux', 'Extra argument'); + } + + /** + * @covers ::pageTextMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::pageTextMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testPageTextMatches(): void { + $this->page->getText()->willReturn('foo bar bar'); + $this->webAssert->pageTextMatches('/foo/', 'Extra argument'); + } + + /** + * @covers ::pageTextNotMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::pageTextNotMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testPageTextNotMatches(): void { + $this->page->getText()->willReturn('foo bar bar'); + $this->webAssert->pageTextNotMatches('/qux/', 'Extra argument'); + } + + /** + * @covers ::responseMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseMatches(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->responseMatches('/foo/', 'Extra argument'); + } + + /** + * @covers ::responseNotMatches + * @expectedDeprecation Calling Drupal\Tests\WebAssert::responseNotMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testResponseNotMatches(): void { + $this->page->getContent()->willReturn('foo bar bar'); + $this->webAssert->responseNotMatches('/qux/', 'Extra argument'); + } + + /** + * @covers ::elementsCount + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementsCount with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementsCount(): void { + $this->page->findAll(Argument::any(), Argument::any())->willReturn(['bar']); + $this->webAssert->elementsCount('xpath', '//foo', 1, NULL, 'Extra argument'); + } + + /** + * @covers ::elementExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementExists with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementExists(): void { + $this->page->find(Argument::any(), Argument::any())->willReturn('bar'); + $this->webAssert->elementExists('xpath', '//foo', NULL, 'Extra argument'); + } + + /** + * @covers ::elementNotExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementNotExists with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementNotExists(): void { + $this->page->find(Argument::any(), Argument::any())->willReturn(NULL); + $this->webAssert->elementNotExists('xpath', '//foo', NULL, 'Extra argument'); + } + + /** + * @covers ::elementTextContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementTextContains with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementTextContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->getText()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementTextContains('xpath', '//foo', 'bar', 'Extra argument'); + } + + /** + * @covers ::elementTextNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementTextNotContains with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementTextNotContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->getText()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementTextNotContains('xpath', '//foo', 'qux', 'Extra argument'); + } + + /** + * @covers ::elementContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementContains with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->getHtml()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementContains('xpath', '//foo', 'bar', 'Extra argument'); + } + + /** + * @covers ::elementNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementNotContains with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementNotContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->getHtml()->willReturn('bar'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementNotContains('xpath', '//foo', 'qux', 'Extra argument'); + } + + /** + * @covers ::elementAttributeExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementAttributeExists with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementAttributeExists(): void { + $element = $this->prophesize(NodeElement::class); + $element->hasAttribute('bar')->willReturn(TRUE); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementAttributeExists('xpath', '//foo', 'bar', 'Extra argument'); + } + + /** + * @covers ::elementAttributeContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementAttributeContains with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementAttributeContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->hasAttribute('bar')->willReturn(TRUE); + $element->getAttribute('bar')->willReturn('baz'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementAttributeContains('xpath', '//foo', 'bar', 'baz', 'Extra argument'); + } + + /** + * @covers ::elementAttributeNotContains + * @expectedDeprecation Calling Drupal\Tests\WebAssert::elementAttributeNotContains with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testElementAttributeNotContains(): void { + $element = $this->prophesize(NodeElement::class); + $element->hasAttribute('bar')->willReturn(TRUE); + $element->getAttribute('bar')->willReturn('baz'); + $this->page->find(Argument::any(), Argument::any())->willReturn($element->reveal()); + $this->webAssert->elementAttributeNotContains('xpath', '//foo', 'bar', 'qux', 'Extra argument'); + } + + /** + * @covers ::fieldExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldExists(): void { + $this->page->findField(Argument::any())->willReturn('bar'); + $this->webAssert->fieldExists('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::fieldNotExists + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldNotExists with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldNotExists(): void { + $this->page->findField(Argument::any())->willReturn(); + $this->webAssert->fieldNotExists('qux', NULL, 'Extra argument'); + } + + /** + * @covers ::fieldValueEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldValueEquals with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldValueEquals(): void { + $field = $this->prophesize(NodeElement::class); + $field->getValue()->willReturn('bar'); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->fieldValueEquals('foo', 'bar', NULL, 'Extra argument'); + } + + /** + * @covers ::fieldValueNotEquals + * @expectedDeprecation Calling Drupal\Tests\WebAssert::fieldValueNotEquals with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testFieldValueNotEquals(): void { + $field = $this->prophesize(NodeElement::class); + $field->getValue()->willReturn('bar'); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->fieldValueNotEquals('foo', 'qux', NULL, 'Extra argument'); + } + + /** + * @covers ::checkboxChecked + * @expectedDeprecation Calling Drupal\Tests\WebAssert::checkboxChecked with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testCheckboxChecked(): void { + $field = $this->prophesize(NodeElement::class); + $field->isChecked()->willReturn(TRUE); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->checkboxChecked('foo', NULL, 'Extra argument'); + } + + /** + * @covers ::checkboxNotChecked + * @expectedDeprecation Calling Drupal\Tests\WebAssert::checkboxNotChecked with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 + */ + public function testCheckboxNotChecked(): void { + $field = $this->prophesize(NodeElement::class); + $field->isChecked()->willReturn(FALSE); + $this->page->findField(Argument::any())->willReturn($field->reveal()); + $this->webAssert->checkboxNotChecked('qux', NULL, 'Extra argument'); + } + + /** + * Returns a mocked behat session object. + * + * @return \Behat\Mink\Session + * The mocked session. + */ + protected function getSession(): Session { + return $this->session->reveal(); + } + +} diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index 5b809a61ae1fcb7b69c7aed163f9b67f0e11ac79..bbf2f4a800de88c915844276a37ba6bdd51eb6ad 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -5,6 +5,7 @@ use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Exception\ResponseTextException; use Behat\Mink\WebAssert as MinkWebAssert; +use Behat\Mink\Element\ElementInterface; use Behat\Mink\Element\TraversableElement; use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Session; @@ -115,6 +116,9 @@ public function responseHeaderDoesNotExist(string $name, string $message = ''): * When the element doesn't exist. */ public function buttonExists($button, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->findButton($button); @@ -137,6 +141,9 @@ public function buttonExists($button, TraversableElement $container = NULL) { * When the button exists. */ public function buttonNotExists($button, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->findButton($button); @@ -158,6 +165,9 @@ public function buttonNotExists($button, TraversableElement $container = NULL) { * When the element doesn't exist. */ public function selectExists($select, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->find('named', [ 'select', @@ -188,6 +198,9 @@ public function selectExists($select, TraversableElement $container = NULL) { * When the element doesn't exist. */ public function optionExists($select, $option, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $select_field = $container->find('named', [ 'select', @@ -221,6 +234,9 @@ public function optionExists($select, $option, TraversableElement $container = N * When the select element doesn't exist. */ public function optionNotExists($select, $option, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $select_field = $container->find('named', [ 'select', @@ -246,6 +262,9 @@ public function optionNotExists($select, $option, TraversableElement $container * Thrown when element doesn't exist, or the title is a different one. */ public function titleEquals($expected_title) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $title_element = $this->session->getPage()->find('css', 'title'); if (!$title_element) { throw new ExpectationException('No title element found on the page', $this->session->getDriver()); @@ -447,6 +466,9 @@ public function buildXPathQuery($xpath, array $args = []) { * Raw (HTML) string to look for. */ public function assertNoEscaped($raw) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $this->responseNotContains(Html::escape($raw)); } @@ -459,6 +481,9 @@ public function assertNoEscaped($raw) { * Raw (HTML) string to look for. */ public function assertEscaped($raw) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $this->responseContains(Html::escape($raw)); } @@ -471,6 +496,9 @@ public function assertEscaped($raw) { * @throws \Behat\Mink\Exception\ExpectationException */ public function responseContains($text) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } parent::responseContains((string) $text); } @@ -483,6 +511,9 @@ public function responseContains($text) { * @throws \Behat\Mink\Exception\ExpectationException */ public function responseNotContains($text) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } parent::responseNotContains((string) $text); } @@ -522,6 +553,9 @@ public function assert($condition, $message) { * @throws \Behat\Mink\Exception\ExpectationException */ public function fieldDisabled($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -551,6 +585,9 @@ public function fieldDisabled($field, TraversableElement $container = NULL) { * @throws \Behat\Mink\Exception\ExpectationException */ public function fieldEnabled($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -579,6 +616,9 @@ public function fieldEnabled($field, TraversableElement $container = NULL) { * @throws \Behat\Mink\Exception\ElementNotFoundException */ public function hiddenFieldExists($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); if ($node = $container->find('hidden_field_selector', ['hidden_field', $field])) { return $node; @@ -597,6 +637,9 @@ public function hiddenFieldExists($field, TraversableElement $container = NULL) * @throws \Behat\Mink\Exception\ExpectationException */ public function hiddenFieldNotExists($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $container = $container ?: $this->session->getPage(); $node = $container->find('hidden_field_selector', ['hidden_field', $field]); $this->assert($node === NULL, "A hidden field '$field' exists on this page, but it should not."); @@ -616,6 +659,9 @@ public function hiddenFieldNotExists($field, TraversableElement $container = NUL * @throws \Behat\Mink\Exception\ExpectationException */ public function hiddenFieldValueEquals($field, $value, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $node = $this->hiddenFieldExists($field, $container); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '$/ui'; @@ -637,6 +683,9 @@ public function hiddenFieldValueEquals($field, $value, TraversableElement $conta * @throws \Behat\Mink\Exception\ExpectationException */ public function hiddenFieldValueNotEquals($field, $value, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $node = $this->hiddenFieldExists($field, $container); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '$/ui'; @@ -653,6 +702,9 @@ public function hiddenFieldValueNotEquals($field, $value, TraversableElement $co * @see \Behat\Mink\WebAssert::pageTextContains() */ public function pageTextContainsOnce($text) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } $actual = $this->session->getPage()->getText(); $actual = preg_replace('/\s+/u', ' ', $actual); $regex = '/' . preg_quote($text, '/') . '/ui'; @@ -687,4 +739,354 @@ public function pageContainsNoDuplicateId() { } } + /** + * {@inheritdoc} + */ + public function addressEquals($page) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::addressEquals($page); + } + + /** + * {@inheritdoc} + */ + public function addressNotEquals($page) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::addressNotEquals($page); + } + + /** + * {@inheritdoc} + */ + public function addressMatches($regex) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::addressMatches($regex); + } + + /** + * {@inheritdoc} + */ + public function cookieEquals($name, $value) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::cookieEquals($name, $value); + } + + /** + * {@inheritdoc} + */ + public function cookieExists($name) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::cookieExists($name); + } + + /** + * {@inheritdoc} + */ + public function statusCodeEquals($code) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::statusCodeEquals($code); + } + + /** + * {@inheritdoc} + */ + public function statusCodeNotEquals($code) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::statusCodeNotEquals($code); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderEquals($name, $value) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderEquals($name, $value); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderNotEquals($name, $value) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderNotEquals($name, $value); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderContains($name, $value) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderContains($name, $value); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderNotContains($name, $value) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderNotContains($name, $value); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderMatches($name, $regex) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderMatches($name, $regex); + } + + /** + * {@inheritdoc} + */ + public function responseHeaderNotMatches($name, $regex) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseHeaderNotMatches($name, $regex); + } + + /** + * {@inheritdoc} + */ + public function pageTextContains($text) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::pageTextContains($text); + } + + /** + * {@inheritdoc} + */ + public function pageTextNotContains($text) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::pageTextNotContains($text); + } + + /** + * {@inheritdoc} + */ + public function pageTextMatches($regex) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::pageTextMatches($regex); + } + + /** + * {@inheritdoc} + */ + public function pageTextNotMatches($regex) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::pageTextNotMatches($regex); + } + + /** + * {@inheritdoc} + */ + public function responseMatches($regex) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseMatches($regex); + } + + /** + * {@inheritdoc} + */ + public function responseNotMatches($regex) { + if (func_num_args() > 1) { + @trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::responseNotMatches($regex); + } + + /** + * {@inheritdoc} + */ + public function elementsCount($selectorType, $selector, $count, ElementInterface $container = NULL) { + if (func_num_args() > 4) { + @trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementsCount($selectorType, $selector, $count, $container); + } + + /** + * {@inheritdoc} + */ + public function elementExists($selectorType, $selector, ElementInterface $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementExists($selectorType, $selector, $container); + } + + /** + * {@inheritdoc} + */ + public function elementNotExists($selectorType, $selector, ElementInterface $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementNotExists($selectorType, $selector, $container); + } + + /** + * {@inheritdoc} + */ + public function elementTextContains($selectorType, $selector, $text) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementTextContains($selectorType, $selector, $text); + } + + /** + * {@inheritdoc} + */ + public function elementTextNotContains($selectorType, $selector, $text) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementTextNotContains($selectorType, $selector, $text); + } + + /** + * {@inheritdoc} + */ + public function elementContains($selectorType, $selector, $html) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementContains($selectorType, $selector, $html); + } + + /** + * {@inheritdoc} + */ + public function elementNotContains($selectorType, $selector, $html) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementNotContains($selectorType, $selector, $html); + } + + /** + * {@inheritdoc} + */ + public function elementAttributeExists($selectorType, $selector, $attribute) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementAttributeExists($selectorType, $selector, $attribute); + } + + /** + * {@inheritdoc} + */ + public function elementAttributeContains($selectorType, $selector, $attribute, $text) { + if (func_num_args() > 4) { + @trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementAttributeContains($selectorType, $selector, $attribute, $text); + } + + /** + * {@inheritdoc} + */ + public function elementAttributeNotContains($selectorType, $selector, $attribute, $text) { + if (func_num_args() > 4) { + @trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::elementAttributeNotContains($selectorType, $selector, $attribute, $text); + } + + /** + * {@inheritdoc} + */ + public function fieldExists($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::fieldExists($field, $container); + } + + /** + * {@inheritdoc} + */ + public function fieldNotExists($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::fieldNotExists($field, $container); + } + + /** + * {@inheritdoc} + */ + public function fieldValueEquals($field, $value, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::fieldValueEquals($field, $value, $container); + } + + /** + * {@inheritdoc} + */ + public function fieldValueNotEquals($field, $value, TraversableElement $container = NULL) { + if (func_num_args() > 3) { + @trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::fieldValueNotEquals($field, $value, $container); + } + + /** + * {@inheritdoc} + */ + public function checkboxChecked($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::checkboxChecked($field, $container); + } + + /** + * {@inheritdoc} + */ + public function checkboxNotChecked($field, TraversableElement $container = NULL) { + if (func_num_args() > 2) { + @trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED); + } + return parent::checkboxNotChecked($field, $container); + } + }