summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2020-12-13 20:34:09 +0100
committerDaniel Weipert <code@drogueronin.de>2020-12-13 20:34:09 +0100
commitd79154b3612ec5c79c2fd81adf3ee40b53f83c69 (patch)
treece0e761c765eb92e8796d17f8488e36556e55145 /tests
Initial commitv1.0.0
Diffstat (limited to 'tests')
-rw-r--r--tests/Test.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/Test.php b/tests/Test.php
new file mode 100644
index 0000000..fd99ace
--- /dev/null
+++ b/tests/Test.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace CardmarketApi\Tests;
+
+use CardmarketApi\OAuthMiddleware;
+use GuzzleHttp\Client;
+use GuzzleHttp\HandlerStack;
+use PHPUnit\Framework\TestCase;
+
+class Test extends TestCase
+{
+ private Client $client;
+
+ public function setUp(): void
+ {
+ // Create default HandlerStack
+ $stack = HandlerStack::create();
+
+ // Add this middleware to the top with `push`
+ $stack->push(new OAuthMiddleware(), 'oauth');
+
+ // Initialize the client with the handler option and cardmarket oauth data
+ $this->client = new Client([
+ 'handler' => $stack,
+ 'http_errors' => false,
+ 'base_uri' => 'https://sandbox.cardmarket.com/ws/v2.0/output.json/',
+ 'cardmarket' => [
+ 'app_token' => $_ENV['CARDMARKET_APP_TOKEN'],
+ 'app_secret' => $_ENV['CARDMARKET_APP_SECRET'],
+ 'access_token' => $_ENV['CARDMARKET_ACCESS_TOKEN'],
+ 'access_token_secret' => $_ENV['CARDMARKET_ACCESS_TOKEN_SECRET'],
+ ],
+ ]);
+ }
+
+ public function testOAuthSuccess()
+ {
+ $response = $this->client->get('account');
+
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+}