-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPPCertificateCredentialTest.php
104 lines (95 loc) · 2.54 KB
/
PPCertificateCredentialTest.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
102
103
104
<?php
/**
* Test class for PPCertificateCredential.
*
*/
class PPCertificateCredentialTest extends PHPUnit_Framework_TestCase
{
/**
* @var PPCertificateCredential
*/
protected $credential;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->credential = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
$this->credential->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 testValidateUname()
{
$this->setExpectedException('PPMissingCredentialException');
$credUname = new PPCertificateCredential("", "1255077037", "cacert.pem");
$credUname->validate();
$setNotExpectedException('PPMissingCredentialException');
$credCorrect = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
$var = $credCorrect->validate();
$this->assertNull($var);
}
/**
* @test
*/
public function testValidatePwd()
{
$this->setExpectedException('PPMissingCredentialException');
$credpwd = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "", "cacert.pem");
$credpwd->validate();
}
/**
* @test
*/
public function testValidateCertPath()
{
$this->setExpectedException('PPMissingCredentialException');
$credCertPath = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "");
$credCertPath->validate();
}
/**
* @test
*/
public function testGetAppId()
{
$credAppid = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
$credAppid->setApplicationId("APP-ID");
$this->assertEquals($credAppid->getApplicationId(), "APP-ID");
}
/**
* @test
*/
public function testGetUserName()
{
$this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->credential->getUserName());
}
/**
* @test
*/
public function testGetPassword()
{
$this->assertEquals('1255077037', $this->credential->getPassword());
}
/**
* @test
*/
public function testGetCertificatePath()
{
$this->assertStringEndsWith(dirname(__FILE__). DIRECTORY_SEPARATOR .'cacert.pem', $this->credential->getCertificatePath());
}
/**@test
*/
public function testGetApplicationId()
{
$this->assertEquals('APP-80W284485P519543T', $this->credential->getApplicationId());
}
}
?>