81cf5c8f17db292867cd5baa6a3cc97dcfda3c7e
[WP-Plugins/glm-member-db-registrations.git] /
1 <?php
2 use PayPal\Core\PPCredentialManager;
3 /**
4  * Test class for PPCredentialManager.
5  *
6  */
7 class PPCredentialManagerTest extends \PHPUnit_Framework_TestCase
8 {
9         /**
10          * @var PPCredentialManager
11          */
12         protected $object;
13
14         private $config = array(
15                         'acct1.UserName' => 'jb-us-seller_api1.paypal.com'      ,
16                         'acct1.Password' => 'WX4WTU3S8MY44S7F'  ,
17                         'acct1.Signature' =>    'AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy'      ,
18                         'acct1.AppId' =>        'APP-80W284485P519543T' ,
19                         'acct2.UserName' =>     'certuser_biz_api1.paypal.com'  ,
20                         'acct2.Password' =>     'D6JNKKULHN3G5B8A'      ,
21                         'acct2.CertPath' =>     'cert_key.pem'  ,
22                         'acct2.AppId' =>        'APP-80W284485P519543T' ,
23                         'http.ConnectionTimeOut' =>     '30'    ,
24                         'http.Retry' =>         '5'     ,
25                         'service.RedirectURL' =>        'https://www.sandbox.paypal.com/webscr&cmd='    ,
26                         'service.DevCentralURL' => 'https://developer.paypal.com'       ,
27                         'service.EndPoint.IPN' => 'https://www.sandbox.paypal.com/cgi-bin/webscr'       ,
28                         'service.EndPoint.AdaptivePayments' => 'https://svcs.sandbox.paypal.com/'       ,
29                         'service.SandboxEmailAddress' => 'platform_sdk_seller@gmail.com',
30                         'log.FileName' => 'PayPal1.log' ,
31                         'log.LogLevel' =>       'INFO'  ,
32                         'log.LogEnabled' =>     '1'     ,
33         
34         
35         );
36         /**
37          * Sets up the fixture, for example, opens a network connection.
38          * This method is called before a test is executed.
39          */
40         protected function setUp()
41         {
42                 $this->object = PPCredentialManager::getInstance($this->config);
43         }
44
45         /**
46          * Tears down the fixture, for example, closes a network connection.
47          * This method is called after a test is executed.
48          */
49         protected function tearDown()
50         {
51         }
52
53         /**
54          * @test
55          */
56         public function testGetInstance()
57         {
58                 $instance = $this->object->getInstance($this->config);
59                 $this->assertTrue($instance instanceof PPCredentialManager);
60         }
61
62         /**
63          * @test
64          */
65         public function testGetSpecificCredentialObject()
66         {
67                 $cred = $this->object->getCredentialObject('jb-us-seller_api1.paypal.com');
68                 $this->assertNotNull($cred);
69                 $this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
70                 
71                 $cred = $this->object->getCredentialObject('certuser_biz_api1.paypal.com');
72                 $this->assertNotNull($cred);
73                 $this->assertEquals('certuser_biz_api1.paypal.com', $cred->getUsername());
74                 $this->assertStringEndsWith('cert_key.pem', $cred->getCertificatePath());               
75         }
76         
77         /**
78          * @test
79          */
80         public function testGetInvalidCredentialObject()
81         {
82                 $this->setExpectedException('PayPal\Exception\PPInvalidCredentialException');
83                 $cred = $this->object->getCredentialObject('invalid_biz_api1.gmail.com');
84         }
85                 
86         /**
87          * @test
88          */
89         public function testGetDefaultCredentialObject()
90         {
91                 $cred = $this->object->getCredentialObject();
92                 $this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
93         }       
94         
95         /**
96          * @test
97          */
98         public function testGetPlatformCredentialObject()
99         {
100                 $cred = $this->object->getCredentialObject();
101                 $this->assertEquals('APP-80W284485P519543T', $cred->getApplicationId());
102         }       
103 }
104 ?>