Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
VaultDataBuilderTest.php
Go to the documentation of this file.
1 <?php
7 
13 use PHPUnit_Framework_MockObject_MockObject as MockObject;
14 
18 class VaultDataBuilderTest extends \PHPUnit\Framework\TestCase
19 {
23  private $subjectReaderMock;
24 
28  private $paymentDataObjectMock;
29 
33  private $paymentInfoMock;
34 
38  private $builder;
39 
40  protected function setUp()
41  {
42  $this->paymentDataObjectMock = $this->createMock(PaymentDataObjectInterface::class);
43 
44  $this->paymentInfoMock = $this->createMock(InfoInterface::class);
45 
46  $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class)
47  ->disableOriginalConstructor()
48  ->setMethods(['readPayment'])
49  ->getMock();
50 
51  $this->builder = new VaultDataBuilder($this->subjectReaderMock);
52  }
53 
60  public function testBuild(array $additionalInfo, array $expected)
61  {
62  $subject = [
63  'payment' => $this->paymentDataObjectMock,
64  ];
65 
66  $this->subjectReaderMock->expects(static::once())
67  ->method('readPayment')
68  ->with($subject)
69  ->willReturn($this->paymentDataObjectMock);
70 
71  $this->paymentDataObjectMock->expects(static::once())
72  ->method('getPayment')
73  ->willReturn($this->paymentInfoMock);
74 
75  $this->paymentInfoMock->expects(static::once())
76  ->method('getAdditionalInformation')
77  ->willReturn($additionalInfo);
78 
79  $actual = $this->builder->build($subject);
80  static::assertEquals($expected, $actual);
81  }
82 
87  public function buildDataProvider()
88  {
89  return [
90  [
91  'additionalInfo' => [
93  ],
94  'expected' => [
95  'options' => [
96  'storeInVaultOnSuccess' => true
97  ]
98  ]
99  ],
100  [
101  'additionalInfo' => [
103  ],
104  'expected' => []
105  ],
106  [
107  'additionalInfo' => [],
108  'expected' => []
109  ],
110  ];
111  }
112 }
return false
Definition: gallery.phtml:36