function FilterAPITest::assertFilterFormatViolation

Checks if an expected violation exists in the given violations.

Parameters

\Symfony\Component\Validator\ConstraintViolationListInterface $violations: The violations to assert.

mixed $invalid_value: The expected invalid value.

1 call to FilterAPITest::assertFilterFormatViolation()
FilterAPITest::testTypedDataAPI in core/modules/filter/tests/src/Kernel/FilterAPITest.php
Tests the function of the typed data type.

File

core/modules/filter/tests/src/Kernel/FilterAPITest.php, line 451

Class

FilterAPITest
Tests the behavior of the API of the Filter module.

Namespace

Drupal\Tests\filter\Kernel

Code

public function assertFilterFormatViolation(ConstraintViolationListInterface $violations, $invalid_value) {
  $filter_format_violation_found = FALSE;
  foreach ($violations as $violation) {
    if ($violation->getRoot() instanceof FilterFormatDataType && $violation->getInvalidValue() === $invalid_value) {
      $filter_format_violation_found = TRUE;
      break;

    }
  }
  $this->assertTrue($filter_format_violation_found, new FormattableMarkup('Validation violation for invalid value "%invalid_value" found', [
    '%invalid_value' => $invalid_value,
  ]));
}

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