function LinkAccessConstraintValidatorTest::testValidate
Tests the access validation constraint for links.
@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 31 
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.
