diff --git a/src/Bridge.php b/src/Bridge.php index cabf86b..742be18 100644 --- a/src/Bridge.php +++ b/src/Bridge.php @@ -7,49 +7,47 @@ use GuzzleHttp\Exception\ClientException; /** - * Class Bridge - * - * @package FindBrok\WatsonBridge + * Class Bridge. */ class Bridge { /** - * API Username + * API Username. * * @var string */ protected $username; /** - * API password + * API password. * * @var string */ protected $password; /** - * API Endpoint for making request + * API Endpoint for making request. * * @var string */ protected $endpoint; /** - * Guzzle http client for performing API request + * Guzzle http client for performing API request. * * @var \GuzzleHttp\Client */ protected $client; /** - * The WatsonToken + * The WatsonToken. * * @var \FindBrok\WatsonBridge\Token */ protected $token; /** - * Decide which method to use when sending request + * Decide which method to use when sending request. * * @var string */ @@ -57,24 +55,24 @@ class Bridge /** * The limit for which we can re request token, - * when performing request + * when performing request. * * @var int */ protected $exceptionThrottle = 0; /** - * Default headers + * Default headers. * * @var array */ protected $headers = [ - 'Accept' => 'application/json', - 'X-Watson-Learning-Opt-Out' => false + 'Accept' => 'application/json', + 'X-Watson-Learning-Opt-Out' => false, ]; /** - * Create a new instance of bridge + * Create a new instance of bridge. * * @param string $username * @param string $password @@ -95,7 +93,7 @@ public function __construct($username, $password, $endpoint) } /** - * Return the authorization for making request + * Return the authorization for making request. * * @return array */ @@ -106,15 +104,16 @@ public function getAuth() } /** - * Appends headers to the request + * Appends headers to the request. * * @param array $headers + * * @return self */ public function appendHeaders($headers = []) { //We have some headers to append - if (! empty($headers)) { + if (!empty($headers)) { //Append headers $this->headers = collect($this->headers)->merge($headers)->all(); } @@ -123,7 +122,7 @@ public function appendHeaders($headers = []) } /** - * Return the headers used for making request + * Return the headers used for making request. * * @return array */ @@ -134,22 +133,23 @@ public function getHeaders() } /** - * Fetch token from Watson and Save it locally + * Fetch token from Watson and Save it locally. * * @param bool $incrementThrottle + * * @return void */ public function fetchToken($incrementThrottle = false) { //Increment throttle if needed - if($incrementThrottle) { + if ($incrementThrottle) { $this->incrementThrottle(); } //Reset Client $this->setClient($this->getAuthorizationEndpoint()); //Get the token response $response = $this->get('v1/token', [ - 'url' => $this->endpoint + 'url' => $this->endpoint, ]); //Extract $token = json_decode($response->getBody()->getContents(), true); @@ -160,14 +160,14 @@ public function fetchToken($incrementThrottle = false) } /** - * Get a token for authorization from Watson or Storage + * Get a token for authorization from Watson or Storage. * * @return string */ public function getToken() { //Token is not valid - if (! $this->token->isValid()) { + if (!$this->token->isValid()) { //Fetch from Watson $this->fetchToken(); } @@ -177,7 +177,7 @@ public function getToken() } /** - * Get the authorization endpoint for getting tokens + * Get the authorization endpoint for getting tokens. * * @return string */ @@ -190,21 +190,22 @@ public function getAuthorizationEndpoint() } /** - * Creates the http client + * Creates the http client. * * @param string $endpoint + * * @return void */ public function setClient($endpoint = null) { //Create client using API endpoint $this->client = new Client([ - 'base_uri' => ! is_null($endpoint) ? $endpoint : $this->endpoint, + 'base_uri' => !is_null($endpoint) ? $endpoint : $this->endpoint, ]); } /** - * Return the Http client instance + * Return the Http client instance. * * @return \GuzzleHttp\Client */ @@ -215,23 +216,25 @@ public function getClient() } /** - * Clean options by removing empty items + * Clean options by removing empty items. * * @param array $options + * * @return array */ public function cleanOptions($options = []) { //If item is null or empty we will remove them return collect($options)->reject(function ($item) { - return (empty($item) || is_null($item)); + return empty($item) || is_null($item); })->all(); } /** - * Failed Request to Watson + * Failed Request to Watson. * * @param \GuzzleHttp\Psr7\Response $response + * * @throws WatsonBridgeException */ public function failedRequest($response) @@ -239,7 +242,7 @@ public function failedRequest($response) //Decode Response $decodedResponse = json_decode($response->getBody()->getContents(), true); //Get error message - $errorMessage = (isset($decodedResponse['error_message']) && ! is_null($decodedResponse['error_message'])) ? + $errorMessage = (isset($decodedResponse['error_message']) && !is_null($decodedResponse['error_message'])) ? $decodedResponse['error_message'] : $response->getReasonPhrase(); //ClientException @@ -247,11 +250,12 @@ public function failedRequest($response) } /** - * Make a Request to Watson with credentials Auth + * Make a Request to Watson with credentials Auth. * * @param string $method * @param string $uri - * @param array $options + * @param array $options + * * @return \GuzzleHttp\Psr7\Response */ public function request($method = 'GET', $uri = '', $options = []) @@ -261,7 +265,7 @@ public function request($method = 'GET', $uri = '', $options = []) return $this->getClient()->request($method, $uri, $this->getRequestOptions($options)); } catch (ClientException $e) { //We are using token auth and probably token expired - if($this->authMethod == 'token' && $e->getCode() == 401 && ! $this->isThrottledReached()) { + if ($this->authMethod == 'token' && $e->getCode() == 401 && !$this->isThrottledReached()) { //Try refresh token $this->fetchToken(true); //Try requesting again @@ -275,15 +279,16 @@ public function request($method = 'GET', $uri = '', $options = []) } /** - * Send a Request to Watson + * Send a Request to Watson. * * @param string $method * @param string $uri - * @param mixed $data + * @param mixed $data * @param string $type + * * @return \GuzzleHttp\Psr7\Response */ - private function send($method = 'POST', $uri, $data, $type = 'json') + private function send($method, $uri, $data, $type = 'json') { //Make the Request to Watson $response = $this->request($method, $uri, [$type => $data]); @@ -297,9 +302,10 @@ private function send($method = 'POST', $uri, $data, $type = 'json') } /** - * Get Request options to pass along + * Get Request options to pass along. * * @param array $initial + * * @return array */ public function getRequestOptions($initial = []) @@ -307,13 +313,13 @@ public function getRequestOptions($initial = []) //Define options $options = collect($initial); //Define an auth option - if($this->authMethod == 'credentials') { + if ($this->authMethod == 'credentials') { $options = $options->merge([ 'auth' => $this->getAuth(), ]); } elseif ($this->authMethod == 'token') { $this->appendHeaders([ - 'X-Watson-Authorization-Token' => $this->getToken() + 'X-Watson-Authorization-Token' => $this->getToken(), ]); } //Put Headers in options @@ -325,9 +331,10 @@ public function getRequestOptions($initial = []) } /** - * Change the auth method + * Change the auth method. * * @param string $method + * * @return self */ public function useAuthMethodAs($method = 'credentials') @@ -339,7 +346,7 @@ public function useAuthMethodAs($method = 'credentials') } /** - * Checks if throttle is reached + * Checks if throttle is reached. * * @return bool */ @@ -349,7 +356,7 @@ public function isThrottledReached() } /** - * Increment throttle + * Increment throttle. * * @return void */ @@ -359,7 +366,7 @@ public function incrementThrottle() } /** - * Clears throttle counter + * Clears throttle counter. * * @return void */ @@ -369,10 +376,11 @@ public function clearThrottle() } /** - * Make a GET Request to Watson + * Make a GET Request to Watson. * * @param string $uri - * @param array $query + * @param array $query + * * @return \GuzzleHttp\Psr7\Response */ public function get($uri = '', $query = []) @@ -382,56 +390,60 @@ public function get($uri = '', $query = []) } /** - * Make a POST Request to Watson + * Make a POST Request to Watson. * * @param string $uri - * @param mixed $data + * @param mixed $data * @param string $type + * * @return \GuzzleHttp\Psr7\Response */ - public function post($uri = '', $data, $type = 'json') + public function post($uri, $data, $type = 'json') { //Make a Post and return response return $this->send('POST', $uri, $data, $type); } /** - * Make a PUT Request to Watson + * Make a PUT Request to Watson. * * @param string $uri * @param $data * @param string $type + * * @return \GuzzleHttp\Psr7\Response */ - public function put($uri = '', $data, $type = 'json') + public function put($uri, $data, $type = 'json') { //Make a Put and return response return $this->send('PUT', $uri, $data, $type); } /** - * Make a PATCH Request to Watson + * Make a PATCH Request to Watson. * * @param string $uri * @param $data * @param string $type + * * @return \GuzzleHttp\Psr7\Response */ - public function patch($uri = '', $data, $type = 'json') + public function patch($uri, $data, $type = 'json') { //Make a Patch and return response return $this->send('PATCH', $uri, $data, $type); } /** - * Make a DELETE Request to Watson + * Make a DELETE Request to Watson. * * @param string $uri * @param $data * @param string $type + * * @return \GuzzleHttp\Psr7\Response */ - public function delete($uri = '', $data, $type = 'json') + public function delete($uri, $data, $type = 'json') { //Make a Delete and return response return $this->send('DELETE', $uri, $data, $type); diff --git a/src/Exceptions/WatsonBridgeException.php b/src/Exceptions/WatsonBridgeException.php index 90e6339..fbe6a48 100644 --- a/src/Exceptions/WatsonBridgeException.php +++ b/src/Exceptions/WatsonBridgeException.php @@ -6,24 +6,22 @@ use RuntimeException; /** - * Class WatsonBridgeException - * - * @package FindBrok\WatsonBridge\Exceptions + * Class WatsonBridgeException. */ class WatsonBridgeException extends RuntimeException { /** - * Default error message + * Default error message. * * @var string */ protected $message = 'An error occurred while performing request to Watson'; /** - * Create a new instance of WatsonBridgeException + * Create a new instance of WatsonBridgeException. * - * @param string $message - * @param int $code + * @param string $message + * @param int $code * @param Exception|null $previous */ public function __construct($message = '', $code = 400, Exception $previous = null) diff --git a/src/Token.php b/src/Token.php index bbfb492..e26cca1 100644 --- a/src/Token.php +++ b/src/Token.php @@ -5,38 +5,36 @@ use Carbon\Carbon; /** - * Class Token - * - * @package FindBrok\WatsonBridge + * Class Token. */ class Token { /** - * Username for which the token belongs + * Username for which the token belongs. * * @var string */ protected $username; /** - * The token payload + * The token payload. * * @var array */ protected $payLoad; /** - * Create a new instance of the Token class + * Create a new instance of the Token class. * * @param string $username - * @param array $payLoad + * @param array $payLoad */ public function __construct($username, $payLoad = []) { //Set Username for token $this->username = $username; //Have payload to set - if(! empty($payLoad)) { + if (!empty($payLoad)) { $this->payLoad = $payLoad; } else { //Load from file @@ -45,17 +43,17 @@ public function __construct($username, $payLoad = []) } /** - * Check if token is loaded in class + * Check if token is loaded in class. * * @return bool */ public function hasPayLoad() { - return ! empty($this->payLoad); + return !empty($this->payLoad); } /** - * Check that token file exists + * Check that token file exists. * * @return bool */ @@ -65,27 +63,27 @@ public function exists() } /** - * Check that token is expired + * Check that token is expired. * * @return bool */ public function isExpired() { - return ($this->hasPayLoad() && ($this->payLoad['created'] + $this->payLoad['expires_in']) < Carbon::now()->format('U')); + return $this->hasPayLoad() && ($this->payLoad['created'] + $this->payLoad['expires_in']) < Carbon::now()->format('U'); } /** - * Check that the token is not expired + * Check that the token is not expired. * * @return bool */ public function isNotExpired() { - return ! $this->isExpired(); + return !$this->isExpired(); } /** - * Check if token is valid + * Check if token is valid. * * @return bool */ @@ -95,14 +93,14 @@ public function isValid() } /** - * Saves a token + * Saves a token. * * @return bool */ public function save() { //No payload to save - if(! $this->hasPayLoad()) { + if (!$this->hasPayLoad()) { return false; } //Save the token @@ -110,7 +108,7 @@ public function save() } /** - * Get the token file path + * Get the token file path. * * @return string */ @@ -120,14 +118,14 @@ public function getFilePath() } /** - * Load payload from file + * Load payload from file. * * @return array */ public function loadPayLoadFromFile() { //Not found - if(! $this->exists()) { + if (!$this->exists()) { //We return empty array return []; } @@ -136,7 +134,7 @@ public function loadPayLoadFromFile() } /** - * Get the payload + * Get the payload. * * @return array */ @@ -146,7 +144,7 @@ public function getPayLoad() } /** - * Get the token + * Get the token. * * @return string|null */ @@ -156,18 +154,19 @@ public function getToken() } /** - * Update the token + * Update the token. * * @param string $token + * * @return bool */ public function updateToken($token) { //Update Payload $this->payLoad = [ - 'token' => $token, + 'token' => $token, 'expires_in' => 3600, - 'created' => Carbon::now()->format('U'), + 'created' => Carbon::now()->format('U'), ]; //Save token return $this->save(); diff --git a/tests/TestBridge.php b/tests/TestBridge.php index 64cb5e3..3c92e6b 100644 --- a/tests/TestBridge.php +++ b/tests/TestBridge.php @@ -10,19 +10,19 @@ use GuzzleHttp\Psr7\Response; /** - * Class TestBridge + * Class TestBridge. */ class TestBridge extends PHPUnit_Framework_TestCase { /** - * Watson bridge + * Watson bridge. * * @var */ protected $bridge; /** - * Setup test + * Setup test. */ public function setUp() { @@ -32,9 +32,9 @@ public function setUp() ->getMock(); $this->createTestTokenFile('token-foo', [ - 'token' => 'someToken', + 'token' => 'someToken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]); $reflected = new ReflectionClass(Bridge::class); @@ -43,7 +43,7 @@ public function setUp() } /** - * TearDown Test + * TearDown Test. */ public function tearDown() { @@ -52,9 +52,10 @@ public function tearDown() } /** - * Return Token Storage Folder + * Return Token Storage Folder. * * @param string $file + * * @return string */ public function getTokenStoragePath($file = '') @@ -63,7 +64,7 @@ public function getTokenStoragePath($file = '') } /** - * Get response body for a token + * Get response body for a token. * * @return string */ @@ -73,10 +74,11 @@ public function getTokenResponseBody() } /** - * Creates a test token file + * Creates a test token file. * * @param string $name - * @param array $data + * @param array $data + * * @return void */ public function createTestTokenFile($name = '', $data = []) @@ -89,9 +91,10 @@ public function createTestTokenFile($name = '', $data = []) } /** - * Delete a test token file + * Delete a test token file. * * @param string $name + * * @return void */ public function deleteTestTokenFile($name = '') @@ -100,7 +103,7 @@ public function deleteTestTokenFile($name = '') } /** - * Test that we are able to create bridge object + * Test that we are able to create bridge object. * * @return voids */ @@ -111,7 +114,7 @@ public function testBridgeObjectCanBeConstructed() } /** - * Test that we get the correct Auth endpoint for getting token + * Test that we get the correct Auth endpoint for getting token. * * @return void */ @@ -125,7 +128,7 @@ public function testGetAuthEndpointMethodCorrectEndpointReturned() } /** - * Test that we can set and reset the client correctly + * Test that we can set and reset the client correctly. * * @return void */ @@ -135,7 +138,7 @@ public function testSetClientMethodClientCorrectlySet() $this->assertInstanceOf(Client::class, $bridge->getClient()); $client = new Client([ - 'base_uri' => 'https://gateway.watsonplatform.net/service/api/' + 'base_uri' => 'https://gateway.watsonplatform.net/service/api/', ]); $this->assertEquals($client->getConfig('base_uri'), $bridge->getClient()->getConfig('base_uri')); @@ -144,7 +147,7 @@ public function testSetClientMethodClientCorrectlySet() } /** - * Test that the getRequestOptions method works correctly + * Test that the getRequestOptions method works correctly. * * @return void */ @@ -163,26 +166,26 @@ public function testGetRequestOptionsMethodWillReturnCorrectOptions() ]; $this->assertEquals([ - 'json' => ['foo' => 'bar'], - 'auth' => ['foo', 'password'], + 'json' => ['foo' => 'bar'], + 'auth' => ['foo', 'password'], 'headers' => [ - 'Accept' => 'application/json', - 'X-Watson-Learning-Opt-Out' => false - ] + 'Accept' => 'application/json', + 'X-Watson-Learning-Opt-Out' => false, + ], ], $this->bridge->useAuthMethodAs('credentials')->getRequestOptions(['json' => $data])); $this->assertEquals([ - 'json' => ['foo' => 'bar'], + 'json' => ['foo' => 'bar'], 'headers' => [ - 'Accept' => 'application/json', - 'X-Watson-Learning-Opt-Out' => false, - 'X-Watson-Authorization-Token' => 'someToken' - ] + 'Accept' => 'application/json', + 'X-Watson-Learning-Opt-Out' => false, + 'X-Watson-Authorization-Token' => 'someToken', + ], ], $this->bridge->useAuthMethodAs('token')->getRequestOptions(['json' => $data])); } /** - * Test a Successful Get request + * Test a Successful Get request. * * @return void */ @@ -201,7 +204,7 @@ public function testGetRequestResponseOk() } /** - * Test that the getToken method works + * Test that the getToken method works. * * @return void */ @@ -223,7 +226,7 @@ public function testGetTokenMethodWhenTokenNotValidAndFetchedFromWatsonWithOkTok } /** - * Test that the getToken method works when token is saved + * Test that the getToken method works when token is saved. * * @return void */ @@ -234,16 +237,16 @@ public function testGetTokenMethodWhenTokenIsAlreadyInCache() /** * Test the getToken method with an expired token, we fetch the token from - * Watson again + * Watson again. * * @return void */ public function testGetTokenMethodWhenTokenExpiredAndFetchTokenAgain() { $this->createTestTokenFile('token-foofoo', [ - 'token' => 'oldToken', + 'token' => 'oldToken', 'expires_in' => 3600, - 'created' => 1463977413 + 'created' => 1463977413, ]); // Create a mock and queue one response @@ -264,38 +267,22 @@ public function testGetTokenMethodWhenTokenExpiredAndFetchTokenAgain() } /** - * Test a Get request which fails + * Test a Get request which fails. * * @expectedException \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException - * - public function testGetRequestWithException() - { - // Create a mock and queue one response - $mock = new MockHandler([ - new ClientException( - 'Watson Error', - new Request('GET', 'version/watson-api-method'), - new Response(400, ['X-Foo' => 'Bar'], collect(['error_code' => 400, 'error_message' => 'Watson Error'])->toJson()) - ) - ]); - $handler = HandlerStack::create($mock); - $client = new Client(['handler' => $handler]); - $this->bridge->method('getClient')->willReturn($client); - - $this->bridge->get('version/watson-api-method', ['foo' => 'bar']); - }*/ + }*/ /** - * Test that when the token is expired we refresh the token and try again + * Test that when the token is expired we refresh the token and try again. * * @return void */ public function testTokenExpiredWhenMakingRequestWeRefreshTokenAndTryAgain() { $this->createTestTokenFile('token-foobar', [ - 'token' => 'oldToken', + 'token' => 'oldToken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]); $expectedResponseBody = collect(['someData' => 'data'])->toJson(); diff --git a/tests/TestToken.php b/tests/TestToken.php index f93baea..7babd2b 100644 --- a/tests/TestToken.php +++ b/tests/TestToken.php @@ -4,33 +4,33 @@ use FindBrok\WatsonBridge\Token; /** - * Class TestToken + * Class TestToken. */ class TestToken extends PHPUnit_Framework_TestCase { /** - * The token object + * The token object. * * @var \FindBrok\WatsonBridge\Token */ protected $token; /** - * Setup test + * Setup test. */ public function setUp() { $this->token = new Token('username'); file_put_contents($this->getTokenStoragePath('token-username.json'), collect([ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ])->toJson(), LOCK_EX); } /** - * Tear down test + * Tear down test. */ public function tearDown() { @@ -40,9 +40,10 @@ public function tearDown() } /** - * Return Token Storage Folder + * Return Token Storage Folder. * * @param string $file + * * @return string */ public function getTokenStoragePath($file = '') @@ -51,7 +52,7 @@ public function getTokenStoragePath($file = '') } /** - * Test that we can create the token object + * Test that we can create the token object. * * @return void */ @@ -62,16 +63,16 @@ public function testTokenObjectCanBeConstructed() } /** - * Test that the method hasPayload works + * Test that the method hasPayload works. * * @return void */ public function testHasPayLoadMethod() { $token = new Token('username', [ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]); $this->assertTrue($token->hasPayLoad()); @@ -80,29 +81,29 @@ public function testHasPayLoadMethod() } /** - * Test that the method isExpired works + * Test that the method isExpired works. * * @return void */ public function testIsExpiredAndIsNotExpiredMethod() { $token = new Token('username', [ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => '3600', - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]); $this->assertTrue($token->isNotExpired()); $token2 = new Token('username2', [ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::createFromFormat('Y-m-d H:i:s', '2016-06-02 00:00:00')->format('U') + 'created' => Carbon::createFromFormat('Y-m-d H:i:s', '2016-06-02 00:00:00')->format('U'), ]); $this->assertTrue($token2->isExpired()); } /** - * Test that the getFilePath method works + * Test that the getFilePath method works. * * @return void */ @@ -115,7 +116,7 @@ public function testGetFilePathMethod() } /** - * Test that the exists method works + * Test that the exists method works. * * @return void */ @@ -127,16 +128,16 @@ public function testExistsMethod() } /** - * Test the save method to see if it works + * Test the save method to see if it works. * * @return void */ public function testSaveMethod() { $payload = [ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]; $token = new Token('username2', $payload); @@ -148,30 +149,30 @@ public function testSaveMethod() } /** - * Test that we can load a token from file and get its payload + * Test that we can load a token from file and get its payload. * * @return void */ public function testLoadFromFileMethodAndGetPayLoadMethod() { file_put_contents($this->getTokenStoragePath('token-username3.json'), collect([ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => 1463977413 + 'created' => 1463977413, ])->toJson(), LOCK_EX); $token = new Token('username3'); $this->assertEquals([ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => 1463977413 + 'created' => 1463977413, ], $token->getPayload()); unlink($this->getTokenStoragePath('token-username3.json')); } /** - * Test to see if the isValid method works + * Test to see if the isValid method works. * * @return void */ @@ -182,9 +183,9 @@ public function testIsValidMethod() $this->assertFalse($token2->isValid()); file_put_contents($this->getTokenStoragePath('token-username3.json'), collect([ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => 1463977413 + 'created' => 1463977413, ])->toJson(), LOCK_EX); $token3 = new Token('username3'); @@ -194,16 +195,16 @@ public function testIsValidMethod() } /** - * Test the getToken method to see if it works + * Test the getToken method to see if it works. * * @return void */ public function testGetTokenMethod() { file_put_contents($this->getTokenStoragePath('token-username3.json'), collect([ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ])->toJson(), LOCK_EX); $token3 = new Token('username3'); @@ -216,16 +217,16 @@ public function testGetTokenMethod() } /** - * Test to see if the Update token method works + * Test to see if the Update token method works. * * @return void */ public function testUpdateTokenMethod() { $payload = [ - 'token' => 'sometoken', + 'token' => 'sometoken', 'expires_in' => 3600, - 'created' => Carbon::now()->format('U') + 'created' => Carbon::now()->format('U'), ]; $token = new Token('username3', $payload); $this->assertEquals('sometoken', $token->getToken());