Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
wazabii8 committed Oct 14, 2024
2 parents 759c068 + b772ec4 commit 7a98a0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
25 changes: 12 additions & 13 deletions tests/unitary-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +27,6 @@

], "Is not a valid port number");

// Test 3
$this->add($request->getUri()->getUserInfo(), [
"isString" => [],
"User validation" => function($value) {
Expand All @@ -38,6 +35,8 @@
}

], "Is not a valid port number");
});

$unit->execute();
$this->add((string)$request->withUri(new \MaplePHP\Http\Uri("https://example.se"))->getUri(), [
"equal" => ["https://example.se"],
], "GetUri expects https://example.se as result");
});

0 comments on commit 7a98a0e

Please sign in to comment.