diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d029591..164e22e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/ diff --git a/composer.json b/composer.json index c8a0c12..772e901 100644 --- a/composer.json +++ b/composer.json @@ -46,5 +46,8 @@ }, "require-dev": { "phpunit/phpunit": ">=3.3.0" + }, + "scripts": { + "test": "phpunit" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2fee318..a176b9f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,4 @@ -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) { + $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(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..8e22f77 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,20 @@ + + * @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';