forked from LiveCarta/PayPal-PHP-SDK
Updating model classes to use dynamic config - Moving common classes to sdk-core-php
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
<?php
|
||||
|
||||
// namespace PayPal\Test\Common;
|
||||
|
||||
use PayPal\Auth\OAuthTokenCredential;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testGetAccessToken() {
|
||||
$cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
|
||||
|
||||
$token = $cred->getAccessToken();
|
||||
$this->assertNotNull($token);
|
||||
|
||||
// Check that we get the same token when issuing a new call before token expiry
|
||||
$newToken = $cred->getAccessToken();
|
||||
$this->assertNotNull($newToken);
|
||||
$this->assertEquals($token, $newToken);
|
||||
|
||||
// sleep(60*8);
|
||||
// $newToken = $cred->getAccessToken();
|
||||
// $this->assertNotNull($newToken);
|
||||
// $this->assertNotEqual($token, $newToken);
|
||||
|
||||
}
|
||||
|
||||
public function testInvalidCredentials() {
|
||||
$this->setExpectedException('\PPConnectionException');
|
||||
$cred = new OAuthTokenCredential('dummy', 'secret');
|
||||
$this->assertNull($cred->getAccessToken());
|
||||
}
|
||||
<?php
|
||||
|
||||
// namespace PayPal\Test\Common;
|
||||
|
||||
use PayPal\Auth\OAuthTokenCredential;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class OAuthTokenCredentialTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testGetAccessToken() {
|
||||
$cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET);
|
||||
$config = \PPConfigManager::getInstance()->getConfigHashmap();
|
||||
|
||||
$token = $cred->getAccessToken($config);
|
||||
$this->assertNotNull($token);
|
||||
|
||||
// Check that we get the same token when issuing a new call before token expiry
|
||||
$newToken = $cred->getAccessToken($config);
|
||||
$this->assertNotNull($newToken);
|
||||
$this->assertEquals($token, $newToken);
|
||||
|
||||
// sleep(60*8);
|
||||
// $newToken = $cred->getAccessToken();
|
||||
// $this->assertNotNull($newToken);
|
||||
// $this->assertNotEqual($token, $newToken);
|
||||
|
||||
}
|
||||
|
||||
public function testInvalidCredentials() {
|
||||
$this->setExpectedException('\PPConnectionException');
|
||||
$cred = new OAuthTokenCredential('dummy', 'secret');
|
||||
$this->assertNull($cred->getAccessToken(\PPConfigManager::getInstance()->getConfigHashmap()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user