-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from bowphp/5.x-refactoring-for-perf
[5.x] Fixes testcase service errors
- Loading branch information
Showing
4 changed files
with
107 additions
and
8 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,38 @@ | ||
<?php | ||
|
||
namespace Bow\Tests\Support; | ||
|
||
use Bow\Http\Client\HttpClient; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HttpClientTest extends TestCase | ||
{ | ||
public function test_get_method() | ||
{ | ||
$http = new HttpClient(); | ||
|
||
$response = $http->get("https://google.com"); | ||
|
||
$this->assertEquals($response->statusCode(), 200); | ||
} | ||
|
||
public function test_get_method_with_custom_headers() | ||
{ | ||
$http = new HttpClient(); | ||
|
||
$http->addHeaders(["X-Api-Key" => "Fake-Key"]); | ||
$response = $http->get("https://google.com"); | ||
|
||
$this->assertEquals($response->statusCode(), 200); | ||
} | ||
|
||
public function test_should_be_fail_with_get_method() | ||
{ | ||
$http = new HttpClient("https://google.com"); | ||
|
||
$http->addHeaders(["X-Api-Key" => "Fake-Key"]); | ||
$response = $http->get("/the-fake-url"); | ||
|
||
$this->assertEquals($response->statusCode(), 404); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Bow\Tests\Support; | ||
|
||
use Bow\Testing\TestCase; | ||
|
||
class TestingTest extends TestCase | ||
{ | ||
/** | ||
* The base url | ||
* | ||
* @var string | ||
*/ | ||
protected ?string $url = "https://google.com"; | ||
|
||
public function test_get_method() | ||
{ | ||
$response = $this->get("/"); | ||
|
||
$response->assertStatus(200); | ||
} | ||
|
||
public function test_get_method_with_custom_headers() | ||
{ | ||
$this->withHeaders(["X-Api-Key" => "Fake-Key"]); | ||
|
||
$response = $this->get("/"); | ||
|
||
$response->assertStatus(200); | ||
} | ||
|
||
public function test_should_be_fail_with_get_method() | ||
{ | ||
$this->withHeaders(["X-Api-Key" => "Fake-Key"]); | ||
|
||
$response = $this->get("/the-fake-url-for-my-testing-please-do-not-block-this"); | ||
|
||
$response->assertStatus(404); | ||
} | ||
} |