2 use PayPal\Auth\PPSignatureCredential;
 
   3 use PayPal\Auth\PPTokenAuthorization;
 
   4 use PayPal\Auth\PPSubjectAuthorization;
 
   6  * Test class for PPSignatureCredential.
 
   9 class PPSignatureCredentialTest extends PHPUnit_Framework_TestCase
 
  12          * @var PPSignatureCredential
 
  14         protected $merchantCredential;
 
  16         protected $platformCredential;
 
  19          * Sets up the fixture, for example, opens a network connection.
 
  20          * This method is called before a test is executed.
 
  22         protected function setUp()
 
  24                 $this->merchantCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
 
  26                 $this->platformCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
 
  27                 $this->platformCredential->setApplicationId("APP-80W284485P519543T");
 
  31          * Tears down the fixture, for example, closes a network connection.
 
  32          * This method is called after a test is executed.
 
  34         protected function tearDown()
 
  41         public function testValidateUsername()
 
  43                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
 
  44                 $cred = new PPSignatureCredential("", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
 
  51         public function testValidatepwd()
 
  53                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
 
  54                 $cred = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
 
  61         public function testGetSignature()
 
  63                 $this->assertEquals('Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf', $this->merchantCredential->getSignature());
 
  68         public function testGetUserName()
 
  70                 $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->merchantCredential->getUserName());
 
  75         public function testGetPassword()
 
  77                 $this->assertEquals('1255077037', $this->merchantCredential->getPassword());
 
  82         public function testGetAppId()
 
  84                 $this->assertEquals('APP-80W284485P519543T', $this->platformCredential->getApplicationId());
 
  87         public function testThirdPartyAuthorization() {
 
  88                 $authorizerEmail = "merchant@domain.com";
 
  89                 $thirdPartyAuth = new PPSubjectAuthorization($authorizerEmail);         
 
  90                 $cred = new PPSignatureCredential("username", "pwd", "signature");
 
  91                 $cred->setThirdPartyAuthorization($thirdPartyAuth);             
 
  92                 $this->assertEquals($cred->getThirdPartyAuthorization()->getSubject(), $authorizerEmail);
 
  94                 $accessToken = "atoken";
 
  95                 $tokenSecret = "asecret";
 
  96                 $thirdPartyAuth = new PPTokenAuthorization($accessToken, $tokenSecret);
 
  97                 $cred->setThirdPartyAuthorization($thirdPartyAuth);
 
  98                 $this->assertEquals($cred->getThirdPartyAuthorization()->getAccessToken(), $accessToken);
 
  99                 $this->assertEquals($cred->getThirdPartyAuthorization()->getTokenSecret(), $tokenSecret);