This repository has been archived by the owner on Mar 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,4 +199,66 @@ public function uriBaseUriProvider() | |
], | ||
]; | ||
} | ||
|
||
/** | ||
* @covers \League\Uri\create | ||
* @covers \League\Uri\Factory | ||
* | ||
* @dataProvider resolveProvider | ||
* | ||
* @param string $base_uri | ||
* @param string $uri | ||
* @param string $expected | ||
*/ | ||
public function testCreateResolve(string $base_uri, string $uri, string $expected) | ||
{ | ||
$this->assertSame($expected, (string) Uri\create($uri, $base_uri)); | ||
} | ||
|
||
public function resolveProvider() | ||
{ | ||
$base_uri = 'http://a/b/c/d;p?q'; | ||
|
||
return [ | ||
'base uri' => [$base_uri, '', $base_uri], | ||
'scheme' => [$base_uri, 'http://d/e/f', 'http://d/e/f'], | ||
'path 1' => [$base_uri, 'g', 'http://a/b/c/g'], | ||
'path 2' => [$base_uri, './g', 'http://a/b/c/g'], | ||
'path 3' => [$base_uri, 'g/', 'http://a/b/c/g/'], | ||
'path 4' => [$base_uri, '/g', 'http://a/g'], | ||
'authority' => [$base_uri, '//g', 'http://g'], | ||
'query' => [$base_uri, '?y', 'http://a/b/c/d;p?y'], | ||
'path + query' => [$base_uri, 'g?y', 'http://a/b/c/g?y'], | ||
'fragment' => [$base_uri, '#s', 'http://a/b/c/d;p?q#s'], | ||
'path + fragment' => [$base_uri, 'g#s', 'http://a/b/c/g#s'], | ||
'path + query + fragment' => [$base_uri, 'g?y#s', 'http://a/b/c/g?y#s'], | ||
'single dot 1' => [$base_uri, '.', 'http://a/b/c/'], | ||
'single dot 2' => [$base_uri, './', 'http://a/b/c/'], | ||
'single dot 3' => [$base_uri, './g/.', 'http://a/b/c/g/'], | ||
'single dot 4' => [$base_uri, 'g/./h', 'http://a/b/c/g/h'], | ||
'double dot 1' => [$base_uri, '..', 'http://a/b/'], | ||
'double dot 2' => [$base_uri, '../', 'http://a/b/'], | ||
'double dot 3' => [$base_uri, '../g', 'http://a/b/g'], | ||
'double dot 4' => [$base_uri, '../..', 'http://a/'], | ||
'double dot 5' => [$base_uri, '../../', 'http://a/'], | ||
'double dot 6' => [$base_uri, '../../g', 'http://a/g'], | ||
'double dot 7' => [$base_uri, '../../../g', 'http://a/g'], | ||
'double dot 8' => [$base_uri, '../../../../g', 'http://a/g'], | ||
'double dot 9' => [$base_uri, 'g/../h' , 'http://a/b/c/h'], | ||
'mulitple slashes' => [$base_uri, 'foo////g', 'http://a/b/c/foo////g'], | ||
'complex path 1' => [$base_uri, ';x', 'http://a/b/c/;x'], | ||
'complex path 2' => [$base_uri, 'g;x', 'http://a/b/c/g;x'], | ||
'complex path 3' => [$base_uri, 'g;x?y#s', 'http://a/b/c/g;x?y#s'], | ||
'complex path 4' => [$base_uri, 'g;x=1/./y', 'http://a/b/c/g;x=1/y'], | ||
'complex path 5' => [$base_uri, 'g;x=1/../y', 'http://a/b/c/y'], | ||
'dot segments presence 1' => [$base_uri, '/./g', 'http://a/g'], | ||
'dot segments presence 2' => [$base_uri, '/../g', 'http://a/g'], | ||
'dot segments presence 3' => [$base_uri, 'g.', 'http://a/b/c/g.'], | ||
'dot segments presence 4' => [$base_uri, '.g', 'http://a/b/c/.g'], | ||
'dot segments presence 5' => [$base_uri, 'g..', 'http://a/b/c/g..'], | ||
'dot segments presence 6' => [$base_uri, '..g', 'http://a/b/c/..g'], | ||
'origin uri without path' => ['http://h:b@a', 'b/../y', 'http://h:b@a/y'], | ||
'uri without auhtority' => ['mailto:[email protected]', '[email protected]?subject=baz', 'mailto:[email protected]?subject=baz'], | ||
]; | ||
} | ||
} |