function LinkExternalProtocolsConstraintValidatorTest::testValidateWithMalformedUri

Same name in other branches
  1. 9 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidateWithMalformedUri()
  2. 10 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidateWithMalformedUri()
  3. 11.x core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::testValidateWithMalformedUri()

@covers ::validate

See also

\Drupal\Core\Url::fromUri

File

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

Class

LinkExternalProtocolsConstraintValidatorTest
@coversDefaultClass \Drupal\link\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidator @group Link

Namespace

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

Code

public function testValidateWithMalformedUri() {
    $link = $this->createMock('Drupal\\link\\LinkItemInterface');
    $link->expects($this->any())
        ->method('getUrl')
        ->willThrowException(new \InvalidArgumentException());
    $context = $this->createMock(ExecutionContextInterface::class);
    $context->expects($this->never())
        ->method('addViolation');
    $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.