function UrlHelperTest::providerTestParse

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestParse()
  2. 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestParse()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestParse()

Provides data for self::testParse().

Return value

array

File

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

Class

UrlHelperTest
@group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerTestParse() {
    return [
        [
            'http://www.example.com/my/path',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [],
                'fragment' => '',
            ],
        ],
        [
            'http://www.example.com/my/path?destination=home#footer',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [
                    'destination' => 'home',
                ],
                'fragment' => 'footer',
            ],
        ],
        'absolute fragment, no query' => [
            'http://www.example.com/my/path#footer',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [],
                'fragment' => 'footer',
            ],
        ],
        [
            'http://',
            [
                'path' => '',
                'query' => [],
                'fragment' => '',
            ],
        ],
        [
            'https://',
            [
                'path' => '',
                'query' => [],
                'fragment' => '',
            ],
        ],
        [
            '/my/path?destination=home#footer',
            [
                'path' => '/my/path',
                'query' => [
                    'destination' => 'home',
                ],
                'fragment' => 'footer',
            ],
        ],
        'relative fragment, no query' => [
            '/my/path#footer',
            [
                'path' => '/my/path',
                'query' => [],
                'fragment' => 'footer',
            ],
        ],
        'URL with two question marks, not encoded' => [
            'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10#footer',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [
                    'destination' => 'home',
                    'search' => 'http://www.example.com/search?limit=10',
                ],
                'fragment' => 'footer',
            ],
        ],
        'URL with three question marks, not encoded' => [
            'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10&referer=http://www.example.com/my/path?destination=home&other#footer',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [
                    'destination' => 'home',
                    'search' => 'http://www.example.com/search?limit=10',
                    'referer' => 'http://www.example.com/my/path?destination=home',
                    'other' => '',
                ],
                'fragment' => 'footer',
            ],
        ],
        'URL with three question marks, encoded' => [
            'http://www.example.com/my/path?destination=home&search=http://www.example.com/search?limit=10&referer=http%3A%2F%2Fwww.example.com%2Fmy%2Fpath%3Fdestination%3Dhome%26other#footer',
            [
                'path' => 'http://www.example.com/my/path',
                'query' => [
                    'destination' => 'home',
                    'search' => 'http://www.example.com/search?limit=10',
                    'referer' => 'http://www.example.com/my/path?destination=home&other',
                ],
                'fragment' => 'footer',
            ],
        ],
    ];
}

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