Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirn-se committed Mar 3, 2024
1 parent 5b46733 commit eeddb50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"require-dev": {
"phpunit/phpunit": "^9.0 | ^10.0 | ^11.0",
"php-coveralls/php-coveralls": "^2.0",
"phrity/util-errorhandler": "^1.0",
"squizlabs/php_codesniffer": "^3.0"
},
"suggest": {
Expand Down
21 changes: 19 additions & 2 deletions tests/UriExtensionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Phrity\Util\ErrorHandler;
use Psr\Http\Message\UriInterface;
use JsonSerializable;
use Stringable;
Expand Down Expand Up @@ -234,7 +235,7 @@ public function testComponents(): void
$this->assertEquals(parse_url($uri_str), $uri->getComponents());
}

public function testQueryHelpers2(): void
public function testQueryHelperNonAscii(): void
{
$uri = new Uri('http://domain.tld:80/path?aaa=ö +-:;%C3%B6');
$this->assertEquals('aaa=%C3%B6%20+-:;%C3%B6', $uri->getQuery());
Expand All @@ -247,7 +248,7 @@ public function testQueryHelpers2(): void
$this->assertEquals('å -+:;å', $uri->getQueryItem('aaa'));
}

public function testQueryHelpers(): void
public function testQueryHelperArrays(): void
{
$uri = new Uri('http://domain.tld:80/path?arr%5B0%5D=arr1&arr%5B1%5D=arr2#fragment');
$this->assertEquals([
Expand Down Expand Up @@ -278,4 +279,20 @@ public function testQueryHelpers(): void
'arr' => ['arr1', 'arr2', 'arr3'],
], $uri->getQueryItems());
}

public function testDeprecation(): void
{
$handler = new ErrorHandler();
$uri = new Uri('https://xn--zca0cg32z7rau82strvd.com');
$handler->with(function () use ($uri) {
$uri->getHost(Uri::IDNA);
}, function ($error) {
$this->assertEquals('Flag IDNA is deprecated; use IDN_ENCODE instead', $error->getMessage());
});
$handler->with(function () use ($uri) {
$uri->withHost('xn--zca0cg32z7rau82strvd.com', Uri::IDNA);
}, function ($error) {
$this->assertEquals('Flag IDNA is deprecated; use IDN_ENCODE instead', $error->getMessage());
});
}
}

0 comments on commit eeddb50

Please sign in to comment.