You are here

protected function AssertLegacyTrait::assertNoFieldByXPath in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertNoFieldByXPath()

Asserts that a field does not exist or its value does not match, by XPath.

Parameters

string $xpath: XPath used to find the field.

string $value: (optional) Value of the field, to assert that the field's value on the page does not match it.

string $message: (optional) A message to display with the assertion. Do not translate messages with t().

Throws

\Behat\Mink\Exception\ExpectationException

Deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and assert that the result is empty.

23 calls to AssertLegacyTrait::assertNoFieldByXPath()
AssertLegacyTrait::assertNoField in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field does NOT exist with the given name or ID.
AssertLegacyTrait::assertNoFieldById in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field does not exist with the given ID and value.
AssertLegacyTrait::assertNoFieldByName in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field does not exist with the given name and value.
BlockContentCreationTest::testBlockContentCreation in core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
Creates a "Basic page" block and verifies its consistency in the database.
BlockTest::testBlock in core/modules/block/tests/src/Functional/BlockTest.php
Test configuring and moving a module-define block to specific regions.

... See full list

File

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

Class

AssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\FunctionalTests

Code

protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
  $fields = $this
    ->xpath($xpath);
  if (!empty($fields)) {
    if (isset($value)) {
      $found = FALSE;
      try {
        $this
          ->assertFieldsByValue($fields, $value);
        $found = TRUE;
      } catch (\Exception $e) {
      }
      if ($found) {
        throw new ExpectationException(sprintf('The field resulting from %s was found with the provided value %s.', $xpath, $value), $this
          ->getSession()
          ->getDriver());
      }
    }
    else {
      throw new ExpectationException(sprintf('The field resulting from %s was found.', $xpath), $this
        ->getSession()
        ->getDriver());
    }
  }
}