2d48a9dd645c3790d349074ccb38b781d3ee9404
[WP-Plugins/glm-member-db.git] /
1 <?php
2 use PayPal\Auth\PPSignatureCredential;
3 use PayPal\Auth\PPTokenAuthorization;
4 use PayPal\Auth\PPSubjectAuthorization;
5 /**
6  * Test class for PPSignatureCredential.
7  *
8  */
9 class PPSignatureCredentialTest extends PHPUnit_Framework_TestCase
10 {
11         /**
12          * @var PPSignatureCredential
13          */
14         protected $merchantCredential;
15
16         protected $platformCredential;
17
18         /**
19          * Sets up the fixture, for example, opens a network connection.
20          * This method is called before a test is executed.
21          */
22         protected function setUp()
23         {
24                 $this->merchantCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
25
26                 $this->platformCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
27                 $this->platformCredential->setApplicationId("APP-80W284485P519543T");
28         }
29
30         /**
31          * Tears down the fixture, for example, closes a network connection.
32          * This method is called after a test is executed.
33          */
34         protected function tearDown()
35         {
36         }
37
38         /**
39          * @test
40          */
41         public function testValidateUsername()
42         {
43                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
44                 $cred = new PPSignatureCredential("", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
45                 $cred->validate();
46         }
47
48         /**
49          * @test
50          */
51         public function testValidatepwd()
52         {
53                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
54                 $cred = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
55                 $cred->validate();
56         }
57
58         /**
59          * @test
60          */
61         public function testGetSignature()
62         {
63                 $this->assertEquals('Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf', $this->merchantCredential->getSignature());
64         }
65         /**
66          * @test
67          */
68         public function testGetUserName()
69         {
70                 $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->merchantCredential->getUserName());
71         }
72         /**
73          * @test
74          */
75         public function testGetPassword()
76         {
77                 $this->assertEquals('1255077037', $this->merchantCredential->getPassword());
78         }
79         /**
80          * @test
81          */
82         public function testGetAppId()
83         {
84                 $this->assertEquals('APP-80W284485P519543T', $this->platformCredential->getApplicationId());
85         }
86         
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);
93                 
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);
100         }
101
102 }
103 ?>