Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * Test to see if the isValid method works.
  *
  * @return void
  */
 public function testIsValidMethod()
 {
     $this->assertTrue($this->token->isValid());
     $token2 = new Token('username2');
     $this->assertFalse($token2->isValid());
     $this->createTestTokenFile('token-username3', ['token' => 'sometoken', 'expires_in' => 3600, 'created' => 1463977413]);
     $token3 = new Token('username3');
     $this->assertFalse($token3->isValid());
     $this->deleteTestTokenFile('token-username3');
 }