|
6 | 6 |
|
7 | 7 | class CreatePaymentMethodRequestTest extends TestCase |
8 | 8 | { |
9 | | - /** |
10 | | - * @var CreatePaymentMethodRequest |
11 | | - */ |
12 | | - private $request; |
13 | | - |
14 | | - public function setUp() |
| 9 | + public function testGetData() |
15 | 10 | { |
16 | | - $this->request = new CreatePaymentMethodRequest($this->getHttpClient(), $this->getHttpRequest(), \Braintree_Configuration::gateway()); |
17 | | - $this->request->initialize( |
| 11 | + $request = $this->createPaymentMethodRequest(); |
| 12 | + $request->initialize( |
18 | 13 | array( |
19 | 14 | 'customerId' => '4815162342', |
20 | 15 | 'token' => 'abc123', |
21 | 16 | 'verifyCard' => true, |
22 | 17 | 'verificationMerchantAccountId' => '123581321', |
23 | 18 | ) |
24 | 19 | ); |
| 20 | + |
| 21 | + $expectedData = array( |
| 22 | + 'customerId' => '4815162342', |
| 23 | + 'paymentMethodNonce' => 'abc123', |
| 24 | + 'options' => array( |
| 25 | + 'verifyCard' => true, |
| 26 | + 'verificationMerchantAccountId' => '123581321', |
| 27 | + ) |
| 28 | + ); |
| 29 | + $this->assertSame($expectedData, $request->getData()); |
25 | 30 | } |
26 | 31 |
|
27 | | - public function testGetData() |
| 32 | + public function testGetDataWithCardholderName() |
28 | 33 | { |
| 34 | + $request = $this->createPaymentMethodRequest(); |
| 35 | + $request->initialize( |
| 36 | + array( |
| 37 | + 'customerId' => '4815162342', |
| 38 | + 'token' => 'abc123', |
| 39 | + 'cardholderName' => 'John Yolo', |
| 40 | + 'verifyCard' => true, |
| 41 | + 'verificationMerchantAccountId' => '123581321', |
| 42 | + ) |
| 43 | + ); |
| 44 | + |
29 | 45 | $expectedData = array( |
30 | 46 | 'customerId' => '4815162342', |
31 | 47 | 'paymentMethodNonce' => 'abc123', |
| 48 | + 'cardholderName' => 'John Yolo', |
32 | 49 | 'options' => array( |
33 | 50 | 'verifyCard' => true, |
34 | 51 | 'verificationMerchantAccountId' => '123581321', |
35 | 52 | ) |
36 | 53 | ); |
37 | | - $this->assertSame($expectedData, $this->request->getData()); |
| 54 | + $this->assertSame($expectedData, $request->getData()); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return CreatePaymentMethodRequest |
| 59 | + */ |
| 60 | + private function createPaymentMethodRequest() |
| 61 | + { |
| 62 | + return new CreatePaymentMethodRequest($this->getHttpClient(), $this->getHttpRequest(), \Braintree_Configuration::gateway()); |
38 | 63 | } |
39 | 64 | } |
0 commit comments