function LinkAccessConstraintValidatorTest::testValidate
Same name in other branches
- 9 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkAccessConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkAccessConstraintValidatorTest::testValidate()
- 10 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkAccessConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkAccessConstraintValidatorTest::testValidate()
- 11.x 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.