Skip to content

Commit

Permalink
Adding PSR-7 integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed May 28, 2022
1 parent a81ac40 commit 0db72c1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.3.2",
"phpunit/phpunit" : "^9.5.10",
"php-http/psr7-integration-tests": "^1.1",
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpunit/phpunit": "^9.5.10",
"psr/http-factory": "^1.0"
},
"autoload": {
Expand Down
3 changes: 1 addition & 2 deletions src/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use InvalidArgumentException;
use League\Uri\Exceptions\SyntaxError;
use PHPUnit\Framework\TestCase;
use TypeError;

/**
* @group http
Expand Down Expand Up @@ -52,7 +51,7 @@ public function testInvalidPort(): void
*/
public function testThrowTypeErrorOnWrongType(): void
{
self::expectException(TypeError::class);
self::expectException(InvalidArgumentException::class);
Http::createFromString('https://example.com')->withFragment([]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ private function filterString($str): ?string
}

if (!is_scalar($str)) {
throw new TypeError(sprintf('The component must be a string, a scalar or a stringable object %s given.', gettype($str)));
throw new SyntaxError(sprintf('The component must be a string, a scalar or a stringable object; `%s` given.', gettype($str)));
}

$str = (string) $str;
Expand Down
25 changes: 25 additions & 0 deletions src/UriPsr7IntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* League.Uri (https://uri.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace League\Uri;

use Http\Psr7Test\UriIntegrationTest;
use Psr\Http\Message\UriInterface;

final class UriPsr7IntegrationTest extends UriIntegrationTest
{
public function createUri($uri): UriInterface
{
return (new HttpFactory())->createUri($uri);
}
}
3 changes: 2 additions & 1 deletion src/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace League\Uri;

use InvalidArgumentException;
use League\Uri\Exceptions\SyntaxError;
use PHPUnit\Framework\TestCase;
use TypeError;
Expand Down Expand Up @@ -253,7 +254,7 @@ public function testWithSchemeFailedWithInvalidSchemeValue(): void
*/
public function testWithInvalidCharacters(): void
{
self::expectException(TypeError::class);
self::expectException(InvalidArgumentException::class);
Uri::createFromString('')->withPath(date_create());
}

Expand Down

0 comments on commit 0db72c1

Please sign in to comment.