function LinkExternalProtocolsConstraintValidatorTest::testValidate
Same name and namespace in other branches
- 9 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidate()
- 10 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidate()
- 11.x core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidate()
@covers ::validate @dataProvider providerValidate
File
-
core/
modules/ link/ tests/ src/ Unit/ Plugin/ Validation/ Constraint/ LinkExternalProtocolsConstraintValidatorTest.php, line 22
Class
- LinkExternalProtocolsConstraintValidatorTest
- @coversDefaultClass <a href="/api/drupal/core%21modules%21link%21src%21Plugin%21Validation%21Constraint%21LinkExternalProtocolsConstraintValidator.php/class/LinkExternalProtocolsConstraintValidator/8.9.x" title="Validates the LinkExternalProtocols constraint." class="local">\Drupal\link\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidator</a> @group Link
Namespace
Drupal\Tests\link\Unit\Plugin\Validation\ConstraintCode
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');
}
// Setup some more allowed protocols.
UrlHelper::setAllowedProtocols([
'http',
'https',
'magnet',
]);
$constraint = new LinkExternalProtocolsConstraint();
$validator = new LinkExternalProtocolsConstraintValidator();
$validator->initialize($context);
$validator->validate($value, $constraint);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.