function AssertLegacyTrait::assertFieldByName
Same name in other branches
- 8.9.x core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertFieldByName()
Asserts that a field exists with the given name and value.
Parameters
string $name: Name of field to assert.
string $value: (optional) Value of the field to assert. You may pass in NULL (default) to skip checking the actual value, while still checking that the field exists.
Deprecated
in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead.
See also
https://www.drupal.org/node/3129738
1 call to AssertLegacyTrait::assertFieldByName()
- BrowserTestBaseTest::testLegacyFieldAssertsByName in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php - Tests legacy assertFieldByName() and assertNoFieldByName().
File
-
core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php, line 274
Class
- AssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\FunctionalTestsCode
protected function assertFieldByName($name, $value = NULL) {
@trigger_error('AssertLegacyTrait::assertFieldByName() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() 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' => $name,
]);
$this->assertFieldByXPath($xpath, $value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.