function LinkTypeConstraintValidatorTest::testGeneric
Validate a URL in a field that accepts both internal and external URLs.
File
-
core/
modules/ link/ tests/ src/ Unit/ Plugin/ Validation/ Constraint/ LinkTypeConstraintValidatorTest.php, line 164
Class
- LinkTypeConstraintValidatorTest
- Tests LinkTypeConstraintValidator.
Namespace
Drupal\Tests\link\Unit\Plugin\Validation\ConstraintCode
public function testGeneric() : void {
$url = Url::fromRoute('example.existing_route');
$link = $this->createMock(LinkItemInterface::class);
$link->expects($this->once())
->method('getFieldDefinition')
->willReturn($this->getMockFieldDefinition(LinkItemInterface::LINK_GENERIC));
$link->expects($this->once())
->method('getUrl')
->willReturn($url);
$context = $this->createMock(ExecutionContextInterface::class);
$context->expects($this->never())
->method('buildViolation');
$this->doValidate($link, $context);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.