-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setup for integration tests and other fixes (#105)
- Loading branch information
Showing
6 changed files
with
94 additions
and
7 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
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,24 @@ | ||
|
||
- | ||
request: | ||
method: GET | ||
url: 'https://api.chartmogul.com/v1/ping' | ||
headers: | ||
Host: api.chartmogul.com | ||
Authorization: hidden | ||
content-type: application/json | ||
user-agent: chartmogul-php/5.0.1/PHP-7.4 | ||
Expect: '' | ||
response: | ||
status: | ||
http_version: '1.1' | ||
code: '200' | ||
message: OK | ||
headers: | ||
Access-Control-Allow-Credentials: 'true' | ||
Content-Type: application/json | ||
Date: 'Wed, 12 Apr 2023 07:13:41 GMT' | ||
Content-Length: '16' | ||
Connection: keep-alive | ||
body: '{"data":"pong!"}' | ||
index: 0 |
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,23 @@ | ||
<?php | ||
namespace ChartMogul\IntegrationTests; | ||
|
||
use ChartMogul; | ||
use VCR\VCR; | ||
|
||
class IntegrationExampleTest extends IntegrationTestCase | ||
{ | ||
public function testIntegrationExample() | ||
{ | ||
VCR::insertCassette('IntegrationExampleTest.yaml'); | ||
|
||
/* | ||
* When writing the test, set this to your own API key. | ||
* Once all fixtures are recorded, remove the line from your test | ||
* and remove all references to your own API key in the fixtures. | ||
*/ | ||
// $this->setApiKey('<YOUR_API_KEY>'); | ||
|
||
$response = ChartMogul\Ping::ping($this->client); | ||
$this->assertEquals("pong!", $response->data); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
namespace ChartMogul\IntegrationTests; | ||
|
||
use ChartMogul\Configuration; | ||
use ChartMogul\Http\Client; | ||
use VCR\VCR; | ||
|
||
class IntegrationTestCase extends \PHPUnit\Framework\TestCase | ||
{ | ||
public $client = null; | ||
|
||
public function setUp(): void | ||
{ | ||
VCR::configure() | ||
->enableLibraryHooks(['curl']) | ||
->setCassettePath('tests/Fixtures') | ||
->enableRequestMatchers(['method', 'url', 'body', 'query_string']); | ||
VCR::turnOn(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
VCR::eject(); | ||
VCR::turnOff(); | ||
} | ||
|
||
public function setApiKey($apiKey) | ||
{ | ||
$this->client = new Client(new Configuration($apiKey)); | ||
return $this; | ||
} | ||
} |