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

merge-requests/7/head
Lee Rowlands 2020-08-28 12:06:48 +10:00
parent 82949679ce
commit 050b91b764
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
19 changed files with 1028 additions and 42 deletions

View File

@ -141,11 +141,15 @@ JS;
// 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);
}
/**

View File

@ -175,7 +175,8 @@ class CommentAnonymousTest extends CommentTestBase {
// 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 @@ class CommentAnonymousTest extends CommentTestBase {
'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.');

View File

@ -32,7 +32,7 @@ class CommentInterfaceTest extends CommentTestBase {
// 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);

View File

@ -354,7 +354,8 @@ class CommentNonNodeTest extends BrowserTestBase {
// 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 @@ class CommentNonNodeTest extends BrowserTestBase {
'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.');

View File

@ -48,7 +48,7 @@ class CommentTitleTest extends CommentTestBase {
// 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>|');
}
/**

View File

@ -112,7 +112,7 @@ class FileFieldDisplayTest extends FileFieldTestBase {
$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();

View File

@ -367,7 +367,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$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.');

View File

@ -157,12 +157,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
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);
}
}

View File

@ -414,7 +414,7 @@ class PathAliasTest extends PathTestBase {
// 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.

View File

@ -105,13 +105,15 @@ class StatisticsLoggingTest extends BrowserTestBase {
// 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.

View File

@ -31,7 +31,7 @@ class ElementsTableSelectTest extends BrowserTestBase {
$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 @@ class ElementsTableSelectTest extends BrowserTestBase {
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 @@ class ElementsTableSelectTest extends BrowserTestBase {
*/
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 @@ class ElementsTableSelectTest extends BrowserTestBase {
$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 @@ class ElementsTableSelectTest extends BrowserTestBase {
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');
}
/**

View File

@ -66,7 +66,8 @@ class StorageTest extends BrowserTestBase {
$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 @@ class StorageTest extends BrowserTestBase {
$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 @@ class StorageTest extends BrowserTestBase {
// 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.");
}
/**

View File

@ -59,7 +59,7 @@ class RouterTest extends BrowserTestBase {
$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 @@ class RouterTest extends BrowserTestBase {
// 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 @@ class RouterTest extends BrowserTestBase {
// 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 @@ class RouterTest extends BrowserTestBase {
// 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 @@ class RouterTest extends BrowserTestBase {
// 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');
}
/**

View File

@ -109,7 +109,7 @@ class RebuildTest extends WebDriverTestBase {
'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.

View File

@ -122,7 +122,7 @@ class FrameworkTest extends WebDriverTestBase {
// 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?');
}
}

View File

@ -56,7 +56,8 @@ class TaxonomyTermPagerTest extends TaxonomyTestBase {
// 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++) {

View File

@ -140,7 +140,8 @@ abstract class UpdateTestBase extends BrowserTestBase {
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');

View File

@ -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();
}
}

View File

@ -5,6 +5,7 @@ namespace Drupal\Tests;
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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* 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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
* @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 @@ class WebAssert extends MinkWebAssert {
}
}
/**
* {@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);
}
}