function LinkExternalProtocolsConstraintValidatorTest::testValidateIgnoresInternalUrls

Tests validate ignores internal urls.

@legacy-covers ::validate

File

core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php, line 111

Class

LinkExternalProtocolsConstraintValidatorTest
Tests Drupal\link\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidator.

Namespace

Drupal\Tests\link\Unit\Plugin\Validation\Constraint

Code

public function testValidateIgnoresInternalUrls() : void {
  $link = $this->createMock('Drupal\\link\\LinkItemInterface');
  $link->expects($this->any())
    ->method('getUrl')
    ->willReturn(Url::fromRoute('example.test'));
  $context = $this->createMock(ExecutionContextInterface::class);
  $context->expects($this->never())
    ->method('buildViolation');
  $constraint = new LinkExternalProtocolsConstraint();
  $validator = new LinkExternalProtocolsConstraintValidator();
  $validator->initialize($context);
  $validator->validate($link, $constraint);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.