/**
  * Get a token for authorization from Watson or Storage.
  *
  * @return string
  */
 public function getToken()
 {
     //Token is not valid
     if (!$this->token->isValid()) {
         //Fetch from Watson
         $this->fetchToken();
     }
     //Return token
     return $this->token->getToken();
 }
 /**
  * Test to see if the Update token method works.
  *
  * @return void
  */
 public function testUpdateTokenMethod()
 {
     $payload = ['token' => 'sometoken', 'expires_in' => 3600, 'created' => Carbon::now()->format('U')];
     $token = new Token('username3', $payload);
     $this->assertEquals('sometoken', $token->getToken());
     $this->assertTrue($token->updateToken('newToken'));
     $this->assertEquals('newToken', $token->getToken());
     $this->assertFileExists($this->getTokenStoragePath('token-username3.json'));
     $this->deleteTestTokenFile('token-username3');
 }