2 use PayPal\Core\PPCredentialManager;
4 * Test class for PPCredentialManager.
7 class PPCredentialManagerTest extends \PHPUnit_Framework_TestCase
10 * @var PPCredentialManager
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' ,
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' ,
37 * Sets up the fixture, for example, opens a network connection.
38 * This method is called before a test is executed.
40 protected function setUp()
42 $this->object = PPCredentialManager::getInstance($this->config);
46 * Tears down the fixture, for example, closes a network connection.
47 * This method is called after a test is executed.
49 protected function tearDown()
56 public function testGetInstance()
58 $instance = $this->object->getInstance($this->config);
59 $this->assertTrue($instance instanceof PPCredentialManager);
65 public function testGetSpecificCredentialObject()
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());
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());
80 public function testGetInvalidCredentialObject()
82 $this->setExpectedException('PayPal\Exception\PPInvalidCredentialException');
83 $cred = $this->object->getCredentialObject('invalid_biz_api1.gmail.com');
89 public function testGetDefaultCredentialObject()
91 $cred = $this->object->getCredentialObject();
92 $this->assertEquals('jb-us-seller_api1.paypal.com', $cred->getUsername());
98 public function testGetPlatformCredentialObject()
100 $cred = $this->object->getCredentialObject();
101 $this->assertEquals('APP-80W284485P519543T', $cred->getApplicationId());