You are here

public function WebAssertArgumentsTest::testElementAttributeNotContains in Drupal 9

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Assert/WebAssertArgumentsTest.php \Drupal\Tests\Core\Assert\WebAssertArgumentsTest::testElementAttributeNotContains()

@covers ::elementAttributeNotContains

File

core/tests/Drupal/Tests/Core/Assert/WebAssertArgumentsTest.php, line 493

Class

WebAssertArgumentsTest
Tests that calling WebAssert methods with extra arguments leads to errors.

Namespace

Drupal\Tests\Core\Assert

Code

public function testElementAttributeNotContains() : void {
  $this
    ->expectDeprecation('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');
  $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');
}