diff --git a/Uri.php b/Uri.php index 13b2557..0e027a7 100755 --- a/Uri.php +++ b/Uri.php @@ -61,7 +61,7 @@ protected function polyfill() { $this->scheme = "http"; $this->host = "localhost"; - $this->port = 80; + $this->port = null; $this->user = ""; $this->pass = ""; $this->path = ""; diff --git a/composer.json b/composer.json index 0bfc65f..00bf49e 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "maplephp/http", - "version": "v1.2.1", + "version": "v1.2.2", "type": "library", "description": "MaplePHP/Http is a powerful and easy-to-use PHP library that fully supports the PSR-7 HTTP message interfaces.", "keywords": [ diff --git a/tests/unitary-request.php b/tests/unitary-request.php index ea6d867..1319ae2 100644 --- a/tests/unitary-request.php +++ b/tests/unitary-request.php @@ -3,24 +3,22 @@ $unit = new MaplePHP\Unitary\Unit(); // If you build your library right it will become very easy to mock, like I have below. -$request = new MaplePHP\Http\Request( - "POST", // The HTTP Method (GET, POST, PUT, DELETE, PATCH) - "https://admin:mypass@example.com:65535/test.php?id=5221&place=stockholm", // The Request URI - ["Content-Type" => "application/x-www-form-urlencoded"], // Add Headers, empty array is allowed - ["email" => "john.doe@example.com"] // Post data -); // Begin by adding a test -$unit->case("MaplePHP Request URI path test", function() use($request) { +$unit->case("MaplePHP Request URI path test", function() { + $request = new MaplePHP\Http\Request( + "POST", // The HTTP Method (GET, POST, PUT, DELETE, PATCH) + "https://admin:mypass@example.com:65535/test.php?id=5221&place=stockholm", // The Request URI + ["Content-Type" => "application/x-www-form-urlencoded"], // Add Headers, empty array is allowed + ["email" => "john.doe@example.com"] // Post data + ); - // Test 1 $this->add($request->getMethod(), function() { return $this->equal("POST"); }, "HTTP Request method Type is not POST"); - // Adding a error message is not required, but it is highly recommended + // Adding an error message is not required, but it is highly recommended - // Test 2 $this->add($request->getUri()->getPort(), [ "isInt" => [], // Has no arguments = empty array "min" => [1], // Strict way is to pass each argument to array @@ -29,7 +27,6 @@ ], "Is not a valid port number"); - // Test 3 $this->add($request->getUri()->getUserInfo(), [ "isString" => [], "User validation" => function($value) { @@ -38,6 +35,8 @@ } ], "Is not a valid port number"); -}); -$unit->execute(); \ No newline at end of file + $this->add((string)$request->withUri(new \MaplePHP\Http\Uri("https://example.se"))->getUri(), [ + "equal" => ["https://example.se"], + ], "GetUri expects https://example.se as result"); +}); \ No newline at end of file