public function LinkAccessConstraintValidatorTest::testValidate in Drupal 8
Same name and namespace in other branches
- 9 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkAccessConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkAccessConstraintValidatorTest::testValidate()
Tests the \Drupal\link\Plugin\Validation\Constraint\LinkAccessConstraintValidator::validate() method.
@covers ::validate @dataProvider providerValidate
Parameters
\Drupal\link\LinkItemInterface $value: The link item.
\Drupal\Core\Session\AccountProxyInterface $user: The user account.
bool $valid: A boolean indicating if the combination is expected to be valid.
File
- core/
modules/ link/ tests/ src/ Unit/ Plugin/ Validation/ Constraint/ LinkAccessConstraintValidatorTest.php, line 32
Class
- LinkAccessConstraintValidatorTest
- Tests the LinkAccessConstraintValidator validator.
Namespace
Drupal\Tests\link\Unit\Plugin\Validation\ConstraintCode
public function testValidate($value, $user, $valid) {
$context = $this
->createMock(ExecutionContextInterface::class);
if ($valid) {
$context
->expects($this
->never())
->method('addViolation');
}
else {
$context
->expects($this
->once())
->method('addViolation');
}
$constraint = new LinkAccessConstraint();
$validate = new LinkAccessConstraintValidator($user);
$validate
->initialize($context);
$validate
->validate($value, $constraint);
}