6716e4060bf77a241f56f90198c3ada0e1d9ca69
[WP-Plugins/glm-member-db-registrations.git] /
1 <?php
2 use PayPal\Auth\PPCertificateCredential;
3 use PayPal\Exception\PPMissingCredentialException;
4 /**
5  * Test class for PPCertificateCredential.
6  *
7  */
8 class PPCertificateCredentialTest extends \PHPUnit_Framework_TestCase
9 {
10         /**
11          * @var PPCertificateCredential
12          */
13         protected $credential;
14
15         /**
16          * Sets up the fixture, for example, opens a network connection.
17          * This method is called before a test is executed.
18          */
19         protected function setUp()
20         {
21                 $this->credential = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
22                 $this->credential->setApplicationId('APP-80W284485P519543T');
23         }
24
25         /**
26          * Tears down the fixture, for example, closes a network connection.
27          * This method is called after a test is executed.
28          */
29         protected function tearDown()
30         {
31         }
32
33         /**@test
34          */
35         public function testValidateUname()
36         {
37                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
38                 $credUname = new PPCertificateCredential("", "1255077037", "cacert.pem");
39                 $credUname->validate();
40                 $setNotExpectedException('PPMissingCredentialException');
41                 $credCorrect = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
42                 $var = $credCorrect->validate();
43                 $this->assertNull($var);
44         }
45         /**
46          * @test
47          */
48         public function testValidatePwd()
49         {
50                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
51                 $credpwd = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "", "cacert.pem");
52                 $credpwd->validate();
53
54         }
55         /**
56          * @test
57          */
58         public function testValidateCertPath()
59         {
60                 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
61                 $credCertPath = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "");
62                 $credCertPath->validate();
63         }
64         /**
65          * @test
66          */
67         public function testGetAppId()
68         {
69                 $credAppid = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
70                 $credAppid->setApplicationId("APP-ID");
71                 $this->assertEquals($credAppid->getApplicationId(), "APP-ID");
72         }
73
74         /**
75          * @test
76          */
77         public function testGetUserName()
78         {
79                 $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->credential->getUserName());
80
81         }
82
83         /**
84          * @test
85          */
86         public function testGetPassword()
87         {
88                 $this->assertEquals('1255077037', $this->credential->getPassword());
89         }
90
91         /**
92          * @test
93          */
94         public function testGetCertificatePath()
95         {
96                 $this->assertStringEndsWith(dirname(__FILE__). DIRECTORY_SEPARATOR .'cacert.pem', $this->credential->getCertificatePath());
97         }
98
99         /**@test
100          */
101         public function testGetApplicationId()
102         {
103                 $this->assertEquals('APP-80W284485P519543T', $this->credential->getApplicationId());
104         }
105 }
106 ?>