You are here

public function LinkNotExistingInternalConstraintValidatorTest::testValidate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 26
Contains \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkNotExistingInternalConstraintValidatorTest.

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
    ->getMock('Symfony\\Component\\Validator\\ExecutionContextInterface');
  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);
}