Skip to content
Closed
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: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
ini-values: include_path=.:/usr/share/php:pear/usr/share/php
tools: composer:2.2
- name: Install dependencies
run: composer install
- name: Run tests
run: |
composer test
pear run-tests -r tests/
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@
},
"require-dev": {
"phpunit/phpunit": ">=3.3.0"
Copy link
Contributor

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

Copy link
Contributor Author

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:

  • PHPUnit 4.8.36 OK (113 tests, 270 assertions)
  • PHPUnit 12.0.2 OK, but there were issues! / Tests: 113, Assertions: 270, PHPUnit Deprecations: 1.

See here: https://github.com/ktomk/Net_URL2/actions/runs/13295699011

},
"scripts": {
"test": "phpunit"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit bootstrap="Net/URL2.php"
<phpunit bootstrap="tests/bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
24 changes: 17 additions & 7 deletions tests/Net/URL2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function testSetFragment()
* @see testResolveUrls
* @return array
*/
public function provideResolveUrls()
public static function provideResolveUrls()
{
return array(
array(
Expand Down Expand Up @@ -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()
) {
Expand Down Expand Up @@ -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'),
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
) {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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}";
Expand Down Expand Up @@ -762,6 +767,8 @@ public function test19315()
Net_URL2::removeDotSegments($nonStringObject);
} catch (PHPUnit_Framework_Error $error) {
$this->addToAssertionCount(1);
} catch (Throwable $error) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)) {
Expand Down Expand Up @@ -816,7 +823,7 @@ public function test19684()
* @see testConstructSelf
* @return array
*/
public function provideEquivalentUrlLists()
public static function provideEquivalentUrlLists()
{
return array(
// String equivalence:
Expand Down Expand Up @@ -853,6 +860,7 @@ public function provideEquivalentUrlLists()
*
* @dataProvider provideEquivalentUrlLists
*/
#[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')]
public function testNormalize()
{
$urls = func_get_args();
Expand Down Expand Up @@ -897,7 +905,7 @@ public function testMagicSetGet()
* @return array
* @see testComponentRecompositionAndNormalization
*/
public function provideComposedAndNormalized()
public static function provideComposedAndNormalized()
{
return array(
array(''),
Expand Down Expand Up @@ -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);
Expand All @@ -942,6 +951,7 @@ public function testComponentRecompositionAndNormalization($uri)
* @coversNothing
* @return void
*/
#[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')]
public function testConstructSelf()
{
$urls = func_get_args();
Expand Down
20 changes: 20 additions & 0 deletions tests/bootstrap.php
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';