2 use PayPal\Auth\PPCertificateCredential;
3 use PayPal\Exception\PPMissingCredentialException;
5 * Test class for PPCertificateCredential.
8 class PPCertificateCredentialTest extends \PHPUnit_Framework_TestCase
11 * @var PPCertificateCredential
13 protected $credential;
16 * Sets up the fixture, for example, opens a network connection.
17 * This method is called before a test is executed.
19 protected function setUp()
21 $this->credential = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "cacert.pem");
22 $this->credential->setApplicationId('APP-80W284485P519543T');
26 * Tears down the fixture, for example, closes a network connection.
27 * This method is called after a test is executed.
29 protected function tearDown()
35 public function testValidateUname()
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);
48 public function testValidatePwd()
50 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
51 $credpwd = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "", "cacert.pem");
58 public function testValidateCertPath()
60 $this->setExpectedException('PayPal\Exception\PPMissingCredentialException');
61 $credCertPath = new PPCertificateCredential("platfo_1255077030_biz_api1.gmail.com", "1255077037", "");
62 $credCertPath->validate();
67 public function testGetAppId()
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");
77 public function testGetUserName()
79 $this->assertEquals('platfo_1255077030_biz_api1.gmail.com', $this->credential->getUserName());
86 public function testGetPassword()
88 $this->assertEquals('1255077037', $this->credential->getPassword());
94 public function testGetCertificatePath()
96 $this->assertStringEndsWith(dirname(__FILE__). DIRECTORY_SEPARATOR .'cacert.pem', $this->credential->getCertificatePath());
101 public function testGetApplicationId()
103 $this->assertEquals('APP-80W284485P519543T', $this->credential->getApplicationId());