-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPPSignatureCredentialTest.php
101 lines (90 loc) · 2.87 KB
/
PPSignatureCredentialTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Test class for PPSignatureCredential.
*
*/
class PPSignatureCredentialTest extends PHPUnit_Framework_TestCase
{
/**
* @var PPSignatureCredential
*/
protected $merchantCredential;
protected $platformCredential;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->merchantCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
$this->platformCredential = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
$this->platformCredential->setApplicationId("APP-80W284485P519543T");
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @test
*/
public function testValidateUsername()
{
$this->setExpectedException('PPMissingCredentialException');
$cred = new PPSignatureCredential("", "1255077037","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
$cred->validate();
}
/**
* @test
*/
public function testValidatepwd()
{
$this->setExpectedException('PPMissingCredentialException');
$cred = new PPSignatureCredential("platfo_1255077030_biz_api1.gmail.com", "","Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf");
$cred->validate();
}
/**
* @test
*/
public function testGetSignature()
{
$this->assertEquals('Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf', $this->merchantCredential->getSignature());
}
/**
* @test
*/
public function testGetUserName()
{
$this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->merchantCredential->getUserName());
}
/**
* @test
*/
public function testGetPassword()
{
$this->assertEquals('1255077037', $this->merchantCredential->getPassword());
}
/**
* @test
*/
public function testGetAppId()
{
$this->assertEquals('APP-80W284485P519543T', $this->platformCredential->getApplicationId());
}
public function testThirdPartyAuthorization() {
$authorizerEmail = "merchant@domain.com";
$thirdPartyAuth = new PPSubjectAuthorization($authorizerEmail);
$cred = new PPSignatureCredential("username", "pwd", "signature");
$cred->setThirdPartyAuthorization($thirdPartyAuth);
$this->assertEquals($cred->getThirdPartyAuthorization()->getSubject(), $authorizerEmail);
$accessToken = "atoken";
$tokenSecret = "asecret";
$thirdPartyAuth = new PPTokenAuthorization($accessToken, $tokenSecret);
$cred->setThirdPartyAuthorization($thirdPartyAuth);
$this->assertEquals($cred->getThirdPartyAuthorization()->getAccessToken(), $accessToken);
$this->assertEquals($cred->getThirdPartyAuthorization()->getTokenSecret(), $tokenSecret);
}
}
?>