-
Notifications
You must be signed in to change notification settings - Fork 13
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 #80 from voucherifyio/ma/custom-events-tests
Custom-Events Tests
- Loading branch information
Showing
4 changed files
with
85 additions
and
10 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,54 @@ | ||
<?php | ||
|
||
use Voucherify\Test\Helpers\CurlMock; | ||
|
||
use Voucherify\VoucherifyClient; | ||
use Voucherify\ClientException; | ||
|
||
class CustomEventsTest extends PHPUnit_Framework_TestCase | ||
{ | ||
protected static $headers; | ||
protected static $apiId; | ||
protected static $apiKey; | ||
protected static $client; | ||
|
||
public static function setUpBeforeClass() | ||
{ | ||
self::$apiId = "c70a6f00-cf91-4756-9df5-47628850002b"; | ||
self::$apiKey = "3266b9f8-e246-4f79-bdf0-833929b1380c"; | ||
self::$headers = [ | ||
"content-type: application/json", | ||
"x-app-id: " . self::$apiId, | ||
"x-app-token: " . self::$apiKey, | ||
"x-voucherify-channel: PHP-SDK" | ||
]; | ||
self::$client = new VoucherifyClient(self::$apiId, self::$apiKey); | ||
|
||
CurlMock::enable(); | ||
} | ||
|
||
public static function tearDownAfterClass() | ||
{ | ||
CurlMock::disable(); | ||
} | ||
|
||
public function testTrack() | ||
{ | ||
CurlMock::register("https://api.voucherify.io/v1", self::$headers) | ||
->post("/events/", [ | ||
"event" => "php-event", | ||
"customer" => [ | ||
"source_id" => "php-test-customer" | ||
] | ||
]) | ||
->reply(200, [ "status" => "ok" ]); | ||
|
||
$result = self::$client->customEvents->track("php-event", (object)[ | ||
"source_id" => "php-test-customer" | ||
]); | ||
|
||
$this->assertEquals($result, (object)[ "status" => "ok" ]); | ||
|
||
CurlMock::done(); | ||
} | ||
} |