-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New method
Uri::create($uri, $ref = null): Uri
to create an uri wit…
…h reference
- Loading branch information
Showing
4 changed files
with
150 additions
and
72 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
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 |
---|---|---|
|
@@ -20,58 +20,75 @@ class UriTest extends TestCase | |
public function uriDataProvider() | ||
{ | ||
return [// Default values | ||
[new Uri('http', 'www.berlioz-framework.com'), | ||
['scheme' => 'http', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => null, | ||
'path' => '/', | ||
'query' => '', | ||
'fragment' => '', | ||
'userinfo' => '', | ||
'authority' => 'www.berlioz-framework.com'], | ||
'http://www.berlioz-framework.com/'], | ||
// Default password parameter | ||
[new Uri('https', | ||
'www.berlioz-framework.com', | ||
8080, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi'), | ||
['scheme' => 'https', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => 8080, | ||
'path' => '/path/path/index.php', | ||
'query' => 'test=test&test2=test2', | ||
'fragment' => 'fragmentTest', | ||
'userinfo' => 'elgigi', | ||
'authority' => '[email protected]:8080'], | ||
'https://[email protected]:8080/path/path/index.php?test=test&test2=test2#fragmentTest'], | ||
// Complete constructor | ||
[new Uri('https', | ||
'www.berlioz-framework.com', | ||
8080, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi', | ||
'password'), | ||
['scheme' => 'https', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => 8080, | ||
'path' => '/path/path/index.php', | ||
'query' => 'test=test&test2=test2', | ||
'fragment' => 'fragmentTest', | ||
'userinfo' => 'elgigi:password', | ||
'authority' => 'elgigi:[email protected]:8080'], | ||
'https://elgigi:[email protected]:8080/path/path/index.php?test=test&test2=test2#fragmentTest']]; | ||
[ | ||
new Uri('http', 'www.berlioz-framework.com'), | ||
[ | ||
'scheme' => 'http', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => null, | ||
'path' => '/', | ||
'query' => '', | ||
'fragment' => '', | ||
'userinfo' => '', | ||
'authority' => 'www.berlioz-framework.com' | ||
], | ||
'http://www.berlioz-framework.com/' | ||
], | ||
// Default password parameter | ||
[ | ||
new Uri( | ||
'https', | ||
'www.berlioz-framework.com', | ||
8080, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi' | ||
), | ||
[ | ||
'scheme' => 'https', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => 8080, | ||
'path' => '/path/path/index.php', | ||
'query' => 'test=test&test2=test2', | ||
'fragment' => 'fragmentTest', | ||
'userinfo' => 'elgigi', | ||
'authority' => '[email protected]:8080' | ||
], | ||
'https://[email protected]:8080/path/path/index.php?test=test&test2=test2#fragmentTest' | ||
], | ||
// Complete constructor | ||
[ | ||
new Uri( | ||
'https', | ||
'www.berlioz-framework.com', | ||
8080, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi', | ||
'password' | ||
), | ||
[ | ||
'scheme' => 'https', | ||
'host' => 'www.berlioz-framework.com', | ||
'port' => 8080, | ||
'path' => '/path/path/index.php', | ||
'query' => 'test=test&test2=test2', | ||
'fragment' => 'fragmentTest', | ||
'userinfo' => 'elgigi:password', | ||
'authority' => 'elgigi:[email protected]:8080' | ||
], | ||
'https://elgigi:[email protected]:8080/path/path/index.php?test=test&test2=test2#fragmentTest' | ||
] | ||
]; | ||
} | ||
|
||
/** | ||
* Test constructor and getters. | ||
* | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* | ||
* @dataProvider uriDataProvider | ||
*/ | ||
|
@@ -90,9 +107,9 @@ public function testConstructAndGetters(Uri $uri, array $uriValues) | |
/** | ||
* Test static method "createFromString". | ||
* | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* @param string $stringUri String uri | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* @param string $stringUri String uri | ||
* | ||
* @dataProvider uriDataProvider | ||
*/ | ||
|
@@ -103,16 +120,40 @@ public function testCreateFromString(Uri $uri, array $uriValues, string $stringU | |
$this->testConstructAndGetters($newUri, $uriValues); | ||
} | ||
|
||
public function testCreate() | ||
{ | ||
$uri = Uri::createFromString('../qux?foo#bar'); | ||
$ref = Uri::createFromString('https://elgigi:[email protected]:8080/doc/#qux'); | ||
|
||
$newUri = Uri::create($uri, $ref); | ||
|
||
$this->testConstructAndGetters( | ||
$newUri, | ||
[ | ||
'scheme' => 'https', | ||
'host' => 'getberlioz.com', | ||
'port' => 8080, | ||
'path' => '/qux', | ||
'query' => 'foo', | ||
'fragment' => 'bar', | ||
'userinfo' => 'elgigi:password', | ||
'authority' => 'elgigi:[email protected]:8080' | ||
] | ||
); | ||
} | ||
|
||
private function getUriToTest(): Uri | ||
{ | ||
return new Uri('http', | ||
'www.berlioz-framework.com', | ||
null, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi', | ||
'password'); | ||
return new Uri( | ||
'http', | ||
'www.berlioz-framework.com', | ||
null, | ||
'/path/path/index.php', | ||
'test=test&test2=test2', | ||
'fragmentTest', | ||
'elgigi', | ||
'password' | ||
); | ||
} | ||
|
||
public function testWithScheme() | ||
|
@@ -184,14 +225,14 @@ public function testWithFragment() | |
/** | ||
* Test magic method "__toString". | ||
* | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* @param string $stringUri String uri | ||
* @param \Berlioz\Http\Message\Uri $uri Uri | ||
* @param array $uriValues Values to test | ||
* @param string $stringUri String uri | ||
* | ||
* @dataProvider uriDataProvider | ||
*/ | ||
public function testToString(Uri $uri, array $uriValues, string $stringUri) | ||
{ | ||
$this->assertEquals($stringUri, (string) $uri); | ||
$this->assertEquals($stringUri, (string)$uri); | ||
} | ||
} |