Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions test/EasyPost/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,19 @@ public static function basicOrder()

public static function eventJson()
{
return json_encode(self::readFixtureData()['event_body']);
$currentDir = getcwd();
$data = file_get_contents("$currentDir/examples/official/fixtures/event-body.json");

return json_encode(json_decode($data, true));
}

public static function eventBytes()
{
return utf8_encode(json_encode(self::readFixtureData()['event_body']));
$currentDir = getcwd();
$eventBytesFilepath = file("$currentDir/examples/official/fixtures/event-body.json");
$data = $eventBytesFilepath[0];

return utf8_encode(json_encode(json_decode($data, true)));
}

// The credit card details below are for a valid proxy card usable
Expand Down
6 changes: 3 additions & 3 deletions test/EasyPost/RequireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace EasyPost\Test;

// Manually require the library to ensure there are no import errors (eg: when the autoloader is not used)
require 'lib/easypost.php';

class RequireTest extends \PHPUnit\Framework\TestCase
{
/**
* Tests that no errors are thrown when we import the library without using the autoloader.
* Things like missing or extra imports should be caught by this. The actual assertion here
* doesn't matter, only that an import/require error isn't thrown.
* doesn't matter, only that an import/require error isn't thrown when the test suite runs.
*/
public function testRequireLibrary()
{
$apiBase = \EasyPost\EasyPost::getApiBase();
$this->assertEquals('https://api.easypost.com/v2', $apiBase);
$this->expectNotToPerformAssertions();
}
}
4 changes: 2 additions & 2 deletions test/EasyPost/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function testValidateWebhookInvalidSecret()
];

try {
$response = Webhook::validateWebhook(Fixture::eventBytes(), $headers, $webhookSecret);
Webhook::validateWebhook(Fixture::eventBytes(), $headers, $webhookSecret);
} catch (Error $error) {
$this->assertEquals('Webhook received did not originate from EasyPost or had a webhook secret mismatch.', $error->getMessage());
}
Expand All @@ -164,7 +164,7 @@ public function testValidateWebhookMissingSecret()
];

try {
$response = Webhook::validateWebhook(Fixture::eventBytes(), $headers, $webhookSecret);
Webhook::validateWebhook(Fixture::eventBytes(), $headers, $webhookSecret);
} catch (Error $error) {
$this->assertEquals('Webhook received does not contain an HMAC signature.', $error->getMessage());
}
Expand Down