3 // namespace PayPal\Test\Common;
\r
5 use PayPal\Auth\OAuthTokenCredential;
\r
6 use PayPal\Test\Constants;
\r
7 use PayPal\Core\PPConfigManager;
\r
8 use PayPal\Exception\PPConnectionException;
\r
9 class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
\r
11 public function testGetAccessToken() {
\r
12 $cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
\r
13 $config = PPConfigManager::getInstance()->getConfigHashmap();
\r
15 $token = $cred->getAccessToken($config);
\r
16 $this->assertNotNull($token);
\r
18 // Check that we get the same token when issuing a new call before token expiry
\r
19 $newToken = $cred->getAccessToken($config);
\r
20 $this->assertNotNull($newToken);
\r
21 $this->assertEquals($token, $newToken);
\r
24 // $newToken = $cred->getAccessToken();
\r
25 // $this->assertNotNull($newToken);
\r
26 // $this->assertNotEqual($token, $newToken);
\r
30 public function testInvalidCredentials() {
\r
31 $this->setExpectedException('PayPal\Exception\PPConnectionException');
\r
32 $cred = new OAuthTokenCredential('dummy', 'secret');
\r
33 $this->assertNull($cred->getAccessToken(PPConfigManager::getInstance()->getConfigHashmap()));
\r