function LinkTypeConstraintValidatorTest::testBadUrl
Same name and namespace in other branches
- 11.x core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkTypeConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkTypeConstraintValidatorTest::testBadUrl()
Validate a URL that throws an exception.
File
-
core/
modules/ link/ tests/ src/ Unit/ Plugin/ Validation/ Constraint/ LinkTypeConstraintValidatorTest.php, line 127
Class
- LinkTypeConstraintValidatorTest
- Tests LinkTypeConstraintValidator.
Namespace
Drupal\Tests\link\Unit\Plugin\Validation\ConstraintCode
public function testBadUrl() : void {
$link = $this->createMock(LinkItemInterface::class);
$link->expects($this->once())
->method('getFieldDefinition')
->willReturn($this->getMockFieldDefinition(LinkItemInterface::LINK_INTERNAL));
$link->expects($this->once())
->method('getUrl')
->willThrowException(new \InvalidArgumentException());
$constraintViolationBuilder = $this->createMock(ConstraintViolationBuilderInterface::class);
$constraintViolationBuilder->expects($this->once())
->method('atPath')
->with('uri')
->willReturn($constraintViolationBuilder);
$context = $this->createMock(ExecutionContextInterface::class);
$context->expects($this->once())
->method('buildViolation')
->willReturn($constraintViolationBuilder);
$this->doValidate($link, $context);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.