-
Notifications
You must be signed in to change notification settings - Fork 27
Restore Phpunit Tests #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,5 +46,8 @@ | |
| }, | ||
| "require-dev": { | ||
| "phpunit/phpunit": ">=3.3.0" | ||
| }, | ||
| "scripts": { | ||
| "test": "phpunit" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ public function testSetFragment() | |
| * @see testResolveUrls | ||
| * @return array | ||
| */ | ||
| public function provideResolveUrls() | ||
| public static function provideResolveUrls() | ||
| { | ||
| return array( | ||
| array( | ||
|
|
@@ -283,6 +283,7 @@ public function provideResolveUrls() | |
| * @covers Net_URL2::resolve | ||
| * @return void | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideResolveUrls')] | ||
| public function testResolveUrls($baseURL, array $relativeAbsolutePairs, | ||
| array $options = array() | ||
| ) { | ||
|
|
@@ -468,7 +469,7 @@ public function testDontUseBrackets() | |
| * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 | ||
| * @see testExampleUri | ||
| */ | ||
| public function provideExampleUri() | ||
| public static function provideExampleUri() | ||
| { | ||
| return array( | ||
| array('ftp://ftp.is.co.za/rfc/rfc1808.txt'), | ||
|
|
@@ -492,6 +493,7 @@ public function provideExampleUri() | |
| * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 | ||
| * @see testComponentRecompositionAndNormalization | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideExampleUri')] | ||
| public function testExampleUri($uri) | ||
| { | ||
| $url = new Net_URL2($uri); | ||
|
|
@@ -507,7 +509,7 @@ public function testExampleUri($uri) | |
| * @see testRemoveDotSegments | ||
| * @return array | ||
| */ | ||
| public function providePath() | ||
| public static function providePath() | ||
| { | ||
| // The numbers behind are in reference to sections | ||
| // in RFC 3986 5.2.4. Remove Dot Segments | ||
|
|
@@ -542,6 +544,7 @@ public function providePath() | |
| * @covers Net_URL2::removeDotSegments | ||
| * @return void | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('providePath')] | ||
| public function testRemoveDotSegments($path, $assertion) | ||
| { | ||
| $this->assertEquals($assertion, Net_URL2::removeDotSegments($path)); | ||
|
|
@@ -570,7 +573,7 @@ public function testRemoveDotSegmentsLoopLimit() | |
| * @see testGetQueryVariables | ||
| * @return array | ||
| */ | ||
| public function provideQueryStrings() | ||
| public static function provideQueryStrings() | ||
| { | ||
| // If the second (expected) value is set or not null, parse_str() differs. | ||
| // Notes on PHP differences with each entry/block | ||
|
|
@@ -632,6 +635,7 @@ public function provideQueryStrings() | |
| * @covers Net_URL2::_queryKeyBracketOffset | ||
| * @return void | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideQueryStrings')] | ||
| public function testGetQueryVariables($query, $expected = null, | ||
| array $options = array() | ||
| ) { | ||
|
|
@@ -663,7 +667,7 @@ public function testGetQueryVariables($query, $expected = null, | |
| * @return array | ||
| * @see testHostAndPort | ||
| */ | ||
| public function provideHostAndPort() | ||
| public static function provideHostAndPort() | ||
| { | ||
| return array( | ||
| array('[::1]', '[::1]', false), | ||
|
|
@@ -699,6 +703,7 @@ public function provideHostAndPort() | |
| * @link http://tools.ietf.org/html/rfc3986#section-3.2 | ||
| * @link http://tools.ietf.org/html/rfc3986#section-3.2.3 | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideHostAndPort')] | ||
| public function testHostAndPort($authority, $expectedHost, $expectedPort) | ||
| { | ||
| $uri = "http://{$authority}"; | ||
|
|
@@ -762,6 +767,8 @@ public function test19315() | |
| Net_URL2::removeDotSegments($nonStringObject); | ||
| } catch (PHPUnit_Framework_Error $error) { | ||
| $this->addToAssertionCount(1); | ||
| } catch (Throwable $error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throwable is only in PHP7/PHP 8... So this presuambly isn't going to work on some of the old old versions of PHP we're still in theory trying to test on (PHP 5.3)? https://www.php.net/manual/en/class.throwable.php I did query which version of PHP we should be supporting (and such, testing) in https://pear.php.net/bugs/bug.php?id=28662
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not a problem, it's forwards compatible. The tests show that as well and cover PHP 5.3...8.4. |
||
| $this->addToAssertionCount(1); | ||
| } | ||
|
|
||
| if (!isset($error)) { | ||
|
|
@@ -816,7 +823,7 @@ public function test19684() | |
| * @see testConstructSelf | ||
| * @return array | ||
| */ | ||
| public function provideEquivalentUrlLists() | ||
| public static function provideEquivalentUrlLists() | ||
| { | ||
| return array( | ||
| // String equivalence: | ||
|
|
@@ -853,6 +860,7 @@ public function provideEquivalentUrlLists() | |
| * | ||
| * @dataProvider provideEquivalentUrlLists | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] | ||
| public function testNormalize() | ||
| { | ||
| $urls = func_get_args(); | ||
|
|
@@ -897,7 +905,7 @@ public function testMagicSetGet() | |
| * @return array | ||
| * @see testComponentRecompositionAndNormalization | ||
| */ | ||
| public function provideComposedAndNormalized() | ||
| public static function provideComposedAndNormalized() | ||
| { | ||
| return array( | ||
| array(''), | ||
|
|
@@ -926,6 +934,7 @@ public function provideComposedAndNormalized() | |
| * @link https://pear.php.net/bugs/bug.php?id=20418 | ||
| * @see testExampleUri | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideComposedAndNormalized')] | ||
| public function testComponentRecompositionAndNormalization($uri) | ||
| { | ||
| $url = new Net_URL2($uri); | ||
|
|
@@ -942,6 +951,7 @@ public function testComponentRecompositionAndNormalization($uri) | |
| * @coversNothing | ||
| * @return void | ||
| */ | ||
| #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] | ||
| public function testConstructSelf() | ||
| { | ||
| $urls = func_get_args(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Net_URL2, a class representing a URL as per RFC 3986. | ||
| * | ||
| * PHP version 5 | ||
| * | ||
| * @category Networking | ||
| * @package Net_URL2 | ||
| * @author Some Pear Developers <pear@php.net> | ||
| * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause | ||
| * @link https://tools.ietf.org/html/rfc3986 | ||
| */ | ||
|
|
||
| if (!class_exists('PHPUnit_Framework_TestCase')) | ||
| { | ||
| class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); | ||
| } | ||
|
|
||
| require __DIR__ . '/../Net/URL2.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always slightly suspicious of these things apparently working with such old versions... Considering how much these packages like to change things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are, only the output of the test-runner changes a bit:
See here: https://github.com/ktomk/Net_URL2/actions/runs/13295699011