You are here

public function LinkNotExistingInternalConstraintValidatorTest::testValidate in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkNotExistingInternalConstraintValidatorTest::testValidate()
  2. 9 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkNotExistingInternalConstraintValidatorTest::testValidate()

@covers ::validate @dataProvider providerValidate

File

core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidatorTest.php, line 22

Class

LinkNotExistingInternalConstraintValidatorTest
@coversDefaultClass \Drupal\link\Plugin\Validation\Constraint\LinkNotExistingInternalConstraintValidator @group Link

Namespace

Drupal\Tests\link\Unit\Plugin\Validation\Constraint

Code

public function testValidate($value, $valid) {
  $context = $this
    ->createMock(ExecutionContextInterface::class);
  if ($valid) {
    $context
      ->expects($this
      ->never())
      ->method('addViolation');
  }
  else {
    $context
      ->expects($this
      ->once())
      ->method('addViolation');
  }
  $constraint = new LinkNotExistingInternalConstraint();
  $validator = new LinkNotExistingInternalConstraintValidator();
  $validator
    ->initialize($context);
  $validator
    ->validate($value, $constraint);
}