function LinkExternalProtocolsConstraintValidatorTest::providerValidate

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::providerValidate()
  2. 10 core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::providerValidate()
  3. 11.x core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidatorTest.php \Drupal\Tests\link\Unit\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest::providerValidate()

Data provider for ::testValidate

File

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

Class

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

Namespace

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

Code

public function providerValidate() {
    $data = [];
    // Test allowed protocols.
    $data[] = [
        'http://www.drupal.org',
        TRUE,
    ];
    $data[] = [
        'https://www.drupal.org',
        TRUE,
    ];
    $data[] = [
        'magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C',
        TRUE,
    ];
    // Invalid protocols.
    $data[] = [
        'ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt',
        FALSE,
    ];
    foreach ($data as &$single_data) {
        $url = Url::fromUri($single_data[0]);
        $link = $this->createMock('Drupal\\link\\LinkItemInterface');
        $link->expects($this->any())
            ->method('getUrl')
            ->willReturn($url);
        $single_data[0] = $link;
    }
    return $data;
}

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