function UrlHelperTest::providerTestFilterBadProtocol

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestFilterBadProtocol()
  2. 9 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestFilterBadProtocol()
  3. 8.9.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestFilterBadProtocol()
  4. main core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestFilterBadProtocol()

Provides data for self::testTestFilterBadProtocol().

Return value

array An array of test cases with URIs, expected filtered results, and allowed protocols.

File

core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php, line 530

Class

UrlHelperTest
Tests Drupal\Component\Utility\UrlHelper.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerTestFilterBadProtocol() : array {
  return [
    [
      'javascript://example.com?foo&bar',
      '//example.com?foo&bar',
      [
        'http',
        'https',
      ],
    ],
    // Test custom protocols.
[
      'http://example.com?foo&bar',
      '//example.com?foo&bar',
      [
        'https',
      ],
    ],
    // Valid protocol.
[
      'http://example.com?foo&bar',
      'http://example.com?foo&bar',
      [
        'https',
        'http',
      ],
    ],
    // Colon not part of the URL scheme.
[
      '/test:8888?foo&bar',
      '/test:8888?foo&bar',
      [
        'http',
      ],
    ],
  ];
}

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