Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CcTest.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Payment\Model\Method\Cc;
13 
14 class CcTest extends \PHPUnit\Framework\TestCase
15 {
19  private $ccModel;
20 
21  public function setUp()
22  {
23  $objectManager = new ObjectManager($this);
24  $this->ccModel = $objectManager->getObject(Cc::class);
25  }
26 
27  public function testAssignData()
28  {
29  $additionalData = [
30  'cc_type' => 'VI',
31  'cc_owner' => 'Bruce',
32  'cc_number' => '41111111111111',
33  'cc_cid' => '42',
34  'cc_exp_month' => '02',
35  'cc_exp_year' => '30',
36  'cc_ss_issue' => '9',
37  'cc_ss_start_month' => '01',
38  'cc_ss_start_year' => '30'
39  ];
40 
41  $inputData = new DataObject(
42  [
43  PaymentInterface::KEY_ADDITIONAL_DATA => $additionalData
44  ]
45  );
46 
47  $payment = $this->getMockBuilder(Payment::class)
48  ->disableOriginalConstructor()
49  ->getMock();
50 
51  $expectedData = [
52  'cc_type' => 'VI',
53  'cc_owner' => 'Bruce',
54  'cc_last_4' => '1111',
55  'cc_number' => '41111111111111',
56  'cc_cid' => '42',
57  'cc_exp_month' => '02',
58  'cc_exp_year' => '30',
59  'cc_ss_issue' => '9',
60  'cc_ss_start_month' => '01',
61  'cc_ss_start_year' => '30'
62  ];
63 
64  $payment->expects(static::once())
65  ->method('addData')
66  ->with(
67  $expectedData
68  );
69 
70  $this->ccModel->setInfoInstance($payment);
71  $this->ccModel->assignData($inputData);
72  }
73 }
$objectManager
Definition: bootstrap.php:17
$payment
Definition: order.php:17