-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPPCredentialManagerTest.php
81 lines (73 loc) · 1.87 KB
/
PPCredentialManagerTest.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
<?php
/**
* Test class for PPCredentialManager.
*
*/
class PPCredentialManagerTest extends PHPUnit_Framework_TestCase
{
/**
* @var PPCredentialManager
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = PPCredentialManager::getInstance();
}
/**
* 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 testGetInstance()
{
$instance = $this->object->getInstance();
$this->assertTrue($instance instanceof PPCredentialManager);
}
/**
* @test
*/
public function testGetSpecificCredentialObject()
{
$cred = $this->object->getCredentialObject('jb-us-seller_api1.paypal.com');
$this->assertNotNull($cred);
$this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
$cred = $this->object->getCredentialObject('platfo_1255170694_biz_api1.gmail.com');
$this->assertNotNull($cred);
$this->assertEquals('platfo_1255170694_biz_api1.gmail.com', $cred->getUsername());
$this->assertStringEndsWith('cacert.pem', $cred->getCertificatePath());
}
/**
* @test
*/
public function testGetInvalidCredentialObject()
{
$this->setExpectedException('PPInvalidCredentialException');
$cred = $this->object->getCredentialObject('invalid_biz_api1.gmail.com');
}
/**
* @test
*/
public function testGetDefaultCredentialObject()
{
$cred = $this->object->getCredentialObject();
$this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
}
/**
* @test
*/
public function testGetPlatformCredentialObject()
{
$cred = $this->object->getCredentialObject();
$this->assertEquals('APP-80W284485P519543T', $cred->getApplicationId());
}
}
?>