function AssertLegacyTrait::assertNoField

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertNoField()

Asserts that a field does NOT exist with the given name or ID.

Parameters

string $field: Name or ID of field to assert.

Deprecated

in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() instead.

See also

https://www.drupal.org/node/3129738

1 call to AssertLegacyTrait::assertNoField()
BrowserTestBaseTest::testAssertField in core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
Tests legacy field asserts using textfields.

File

core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php, line 362

Class

AssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\FunctionalTests

Code

protected function assertNoField($field) {
    @trigger_error('AssertLegacyTrait::assertNoField() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
    $xpath = $this->assertSession()
        ->buildXPathQuery('//textarea[@name=:value]|//input[@name=:value]|//select[@name=:value]', [
        ':value' => $field,
    ]) . '|' . $this->assertSession()
        ->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [
        ':value' => $field,
    ]);
    $this->assertNoFieldByXPath($xpath);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.