-
Notifications
You must be signed in to change notification settings - Fork 3
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 #1 from cassell/guzzle6
Guzzle6
- Loading branch information
Showing
8 changed files
with
187 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/vendor | ||
.idea | ||
composer.lock | ||
tests | ||
/phpunit.xml |
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
bootstrap="tests/bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Tremendous Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="TREMENDOUS_ENDPOINT" value="https://testflight.tremendous.com/api/v2/"/> | ||
<env name="TREMENDOUS_API_TOKEN" value=""/> | ||
<env name="TREMENDOUS_FUNDING_SOURCE" value=""/> | ||
<env name="TREMENDOUS_TEST_CAMPAIGN_IDENTIFIER" value="" /> | ||
</php> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,107 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use GuzzleHttp\Client; | ||
use PHPUnit\Framework\TestCase; | ||
use Tremendous\Request\CreateOrderRequest; | ||
use Tremendous\Tremendous; | ||
|
||
class ClientTest extends TestCase | ||
{ | ||
/** | ||
* @throws \Tremendous\Exception\CreateOrderException | ||
* @expectedException \Tremendous\Exception\CreateOrderException | ||
* @expectedExceptionMessage Invalid Access token | ||
*/ | ||
public function testFailure() | ||
{ | ||
$faker = \Faker\Factory::create(); | ||
|
||
$fundingSource = (string)getenv('TREMENDOUS_FUNDING_SOURCE'); | ||
|
||
$reward = [ | ||
'campaign_id' => getenv('TREMENDOUS_TEST_CAMPAIGN_IDENTIFIER'), | ||
'value' => [ | ||
'denomination' => 5.00, | ||
'currency_code' => 'USD' | ||
], | ||
'recipient' => [ | ||
'name' => $faker->name(), | ||
'email' => $faker->safeEmail() | ||
], | ||
'delivery' => [ | ||
'method' => 'LINK' | ||
], | ||
]; | ||
|
||
$rewardExternalId = \Faker\Provider\Uuid::uuid(); | ||
|
||
$invalidToken = 'invalid83924ded57c64add9881e70e35f92a46efbccdd1067a4830b6d6d89b4'; | ||
|
||
$config = [ | ||
'base_uri' => (string)getenv('TREMENDOUS_ENDPOINT'), | ||
'headers' => [ | ||
'Authorization' => 'Bearer ' . $invalidToken, | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json' | ||
] | ||
]; | ||
|
||
$httpClient = new Client($config); | ||
|
||
$tremendousApi = new Tremendous($httpClient); | ||
|
||
$orderRequest = new CreateOrderRequest($fundingSource, $reward, $rewardExternalId); | ||
|
||
$tremendousApi->createOrder($orderRequest); | ||
} | ||
|
||
public function testLink() | ||
{ | ||
$faker = \Faker\Factory::create(); | ||
|
||
$fundingSource = (string)getenv('TREMENDOUS_FUNDING_SOURCE'); | ||
|
||
$reward = [ | ||
'campaign_id' => getenv('TREMENDOUS_TEST_CAMPAIGN_IDENTIFIER'), | ||
'value' => [ | ||
'denomination' => 5.00, | ||
'currency_code' => 'USD' | ||
], | ||
'recipient' => [ | ||
'name' => $faker->name(), | ||
'email' => $faker->safeEmail() | ||
], | ||
'delivery' => [ | ||
'method' => 'LINK' | ||
], | ||
]; | ||
|
||
$rewardExternalId = \Faker\Provider\Uuid::uuid(); | ||
|
||
$config = [ | ||
'base_uri' => (string)getenv('TREMENDOUS_ENDPOINT'), | ||
'headers' => [ | ||
'Authorization' => 'Bearer ' . (string)getenv('TREMENDOUS_API_TOKEN'), | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json' | ||
] | ||
]; | ||
|
||
|
||
$httpClient = new Client($config); | ||
|
||
$tremendousApi = new Tremendous($httpClient); | ||
|
||
$orderRequest = new CreateOrderRequest($fundingSource, $reward, $rewardExternalId); | ||
|
||
$order = $tremendousApi->createOrder($orderRequest); | ||
|
||
$this->assertEquals(5.00, $order->getRewards()[0]->getValue()->getDenomination()); | ||
$this->assertEquals('USD', $order->getRewards()[0]->getValue()->getCurrencyCode()); | ||
$this->assertEquals('SUCCEEDED', $order->getRewards()[0]->getDelivery()->getStatus()); | ||
|
||
} | ||
|
||
|
||
} |