Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"source": "https://github.com/pear/Net_URL2"
},
"require": {
"php": ">=5.1.4"
"php": ">=5.3"
},
"autoload": {
"classmap": ["Net/URL2.php"]
Expand All @@ -45,7 +45,7 @@
}
},
"require-dev": {
"phpunit/phpunit": ">=3.3.0"
"phpunit/phpunit": ">=4.8"
},
"scripts": {
"test": "phpunit"
Expand Down
56 changes: 29 additions & 27 deletions tests/Net/URL2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,28 +827,30 @@ public static function provideEquivalentUrlLists()
{
return array(
// String equivalence:
array('http://example.com/', 'http://example.com/'),
array('http://example.com/', 'http://example.com/', true),

// Originally first dataset:
array('http://www.example.com/%9a', 'http://www.example.com/%9A'),
array('http://www.example.com/%9a', 'http://www.example.com/%9A', false),

// Example from RFC 3986 6.2.2.:
array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'),
array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d', false),

// Example from RFC 3986 6.2.2.1.:
array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/'),
array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/', false),

// Example from RFC 3986 6.2.3.:
array(
'http://example.com', 'http://example.com/',
'http://example.com:/', 'http://example.com:80/'
'http://example.com', 'http://example.com/', false
),
array(
'http://example.com:/', 'http://example.com:80/', false
),

// Bug #20161: URLs with "0" as host fail to normalize with empty path
array('http://0/', 'http://0'),
array('http://0/', 'http://0', false),

// Bug #20473: Normalize query and fragment broken
array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar'),
array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar', false),
);
}

Expand All @@ -861,22 +863,19 @@ public static function provideEquivalentUrlLists()
* @dataProvider provideEquivalentUrlLists
*/
#[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')]
public function testNormalize()
public function testNormalize($urlOne, $urlTwo, $identical)
{
$urls = func_get_args();
$urlOne = new Net_Url2($urlOne);
$urlTwo = new Net_Url2($urlTwo);

$this->assertGreaterThanOrEqual(2, count($urls));
if (! $identical) {
$this->assertNotSame($urlOne->__toString(), $urlTwo->__toString());
}

$last = null;
$urlOne->normalize();
$urlTwo->normalize();

foreach ($urls as $index => $url) {
$url = new Net_Url2($url);
$url->normalize();
if ($index) {
$this->assertSame((string)$last, (string)$url);
}
$last = $url;
}
$this->assertSame($urlOne->__toString(), $urlTwo->__toString());
}

/**
Expand Down Expand Up @@ -952,14 +951,17 @@ public function testComponentRecompositionAndNormalization($uri)
* @return void
*/
#[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')]
public function testConstructSelf()
public function testConstructSelf($urlOne, $urlTwo, $identical)
{
$urls = func_get_args();
foreach ($urls as $url) {
$urlA = new Net_URL2($url);
$urlB = new Net_URL2($urlA);
$this->assertSame((string)$urlA, (string)$urlB);
}
$urlOne = new Net_Url2($urlOne);
$urlOneExtended = new Net_Url2($urlOne);

$this->assertSame($urlOne->__toString(), $urlOneExtended->__toString());

$urlTwo = new Net_Url2($urlTwo);
$urlTwoExtended = new Net_Url2($urlTwo);

$this->assertSame($urlTwo->__toString(), $urlTwoExtended->__toString());
}

/**
Expand Down