-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* PHP 7 SDK for the KATANA(tm) Framework (http://katana.kusanagi.io) | ||
* Copyright (c) 2016-2017 KUSANAGI S.L. All rights reserved. | ||
* | ||
* Distributed under the MIT license | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code | ||
* | ||
* @link https://github.com/kusanagi/katana-sdk-php7 | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
* @copyright Copyright (c) 2016-2017 KUSANAGI S.L. (http://kusanagi.io) | ||
*/ | ||
|
||
namespace Katana\Sdk\Tests\Api\Protocol\Http; | ||
|
||
use Katana\Sdk\Api\Protocol\Http\HttpRequest; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HttpRequestTest extends TestCase | ||
{ | ||
public function testHttpMethod() | ||
{ | ||
$httpRequest = new HttpRequest('', 'get', ''); | ||
$this->assertFalse($httpRequest->isMethod('post')); | ||
$this->assertTrue($httpRequest->isMethod('get')); | ||
$this->assertEquals('get', $httpRequest->getMethod()); | ||
} | ||
|
||
public function testEmptyUrl() | ||
{ | ||
$httpRequest = new HttpRequest('', '', ''); | ||
$this->assertEquals('', $httpRequest->getUrl()); | ||
$this->assertEquals('', $httpRequest->getUrlScheme()); | ||
$this->assertEquals('', $httpRequest->getUrlHost()); | ||
$this->assertEquals('', $httpRequest->getUrlPath()); | ||
} | ||
|
||
public function testUrlWithNoPath() | ||
{ | ||
$httpRequest = new HttpRequest('', '', 'https://example.com'); | ||
$this->assertEquals('https://example.com', $httpRequest->getUrl()); | ||
$this->assertEquals('https', $httpRequest->getUrlScheme()); | ||
$this->assertEquals('example.com', $httpRequest->getUrlHost()); | ||
$this->assertEquals('', $httpRequest->getUrlPath()); | ||
} | ||
|
||
public function testFullUrl() | ||
{ | ||
$httpRequest = new HttpRequest('', '', 'https://example.com/path'); | ||
$this->assertEquals('https://example.com/path', $httpRequest->getUrl()); | ||
$this->assertEquals('https', $httpRequest->getUrlScheme()); | ||
$this->assertEquals('example.com', $httpRequest->getUrlHost()); | ||
$this->assertEquals('/path', $httpRequest->getUrlPath()); | ||
} | ||
} |