Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions test/IntercomClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ class IntercomClientTest extends PHPUnit_Framework_TestCase
{
public function testBasicClient()
{
$mock = new MockHandler(
[
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], "{\"foo\":\"bar\"}")
]
);
]);

$container = [];
$history = Middleware::history($container);
Expand All @@ -27,11 +25,9 @@ public function testBasicClient()
$client = new IntercomClient('u', 'p');
$client->setClient($http_client);

$client->users->create(
[
$client->users->create([
'email' => '[email protected]'
]
);
]);

foreach ($container as $transaction) {
$basic = $transaction['request']->getHeaders()['Authorization'][0];
Expand All @@ -41,11 +37,9 @@ public function testBasicClient()

public function testExtendedClient()
{
$mock = new MockHandler(
[
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], "{\"foo\":\"bar\"}")
]
);
]);

$container = [];
$history = Middleware::history($container);
Expand All @@ -57,11 +51,9 @@ public function testExtendedClient()
$client = new IntercomClient('u', 'p', ['connect_timeout' => 10]);
$client->setClient($http_client);

$client->users->create(
[
$client->users->create([
'email' => '[email protected]'
]
);
]);

foreach ($container as $transaction) {
$basic = $client->getGuzzleRequestOptions()['connect_timeout'];
Expand All @@ -72,11 +64,9 @@ public function testExtendedClient()

public function testPaginationHelper()
{
$mock = new MockHandler(
[
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], "{\"foo\":\"bar\"}")
]
);
]);

$container = [];
$history = Middleware::history($container);
Expand All @@ -103,11 +93,17 @@ public function testRateLimitDetails()
{
date_default_timezone_set('UTC');
$time = time() + 7;
$mock = new MockHandler(
[
new Response(200, ['X-RateLimit-Limit' => '83', 'X-RateLimit-Remaining' => '2', 'X-RateLimit-Reset' => $time], "{\"foo\":\"bar\"}")
]
);
$mock = new MockHandler([
new Response(
200,
[
'X-RateLimit-Limit' => '83',
'X-RateLimit-Remaining' => '2',
'X-RateLimit-Reset' => $time
],
"{\"foo\":\"bar\"}"
)
]);

$container = [];
$history = Middleware::history($container);
Expand All @@ -119,11 +115,9 @@ public function testRateLimitDetails()
$client = new IntercomClient('u', 'p');
$client->setClient($http_client);

$client->users->create(
[
$client->users->create([
'email' => '[email protected]'
]
);
]);

$rateLimitDetails = $client->getRateLimitDetails();
$this->assertInternalType('array', $rateLimitDetails);
Expand Down