14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
34 private $paymentDOMock;
44 private $billingAddressMock;
49 private $subjectReaderMock;
61 $this->initOrderMock();
63 $this->paymentDOMock = $this->getMockBuilder(PaymentDataObjectInterface::class)
64 ->disableOriginalConstructor()
65 ->setMethods([
'getOrder',
'getPayment'])
67 $this->paymentDOMock->expects(static::once())
69 ->willReturn($this->orderMock);
71 $this->configMock = $this->getMockBuilder(Config::class)
72 ->setMethods([
'isVerify3DSecure',
'getThresholdAmount',
'get3DSecureSpecificCountries'])
73 ->disableOriginalConstructor()
75 $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class)
76 ->disableOriginalConstructor()
91 public function testBuild($verify, $thresholdAmount, $countryId, array $countries, array $expected)
94 'payment' => $this->paymentDOMock,
98 $this->configMock->expects(static::once())
99 ->method(
'isVerify3DSecure')
100 ->with(self::equalTo($this->storeId))
101 ->willReturn($verify);
103 $this->configMock->expects(static::any())
104 ->method(
'getThresholdAmount')
105 ->with(self::equalTo($this->storeId))
106 ->willReturn($thresholdAmount);
108 $this->configMock->expects(static::any())
109 ->method(
'get3DSecureSpecificCountries')
110 ->with(self::equalTo($this->storeId))
111 ->willReturn($countries);
113 $this->billingAddressMock->expects(static::any())
114 ->method(
'getCountryId')
115 ->willReturn($countryId);
117 $this->subjectReaderMock->expects(self::once())
118 ->method(
'readPayment')
119 ->with($buildSubject)
120 ->willReturn($this->paymentDOMock);
121 $this->subjectReaderMock->expects(self::once())
122 ->method(
'readAmount')
123 ->with($buildSubject)
126 $result = $this->builder->build($buildSubject);
127 self::assertEquals($expected,
$result);
138 [
'verify' =>
true,
'amount' => 20,
'countryId' =>
'US',
'countries' => [],
'result' => [
140 'three_d_secure' => [
145 [
'verify' =>
true,
'amount' => 0,
'countryId' =>
'US',
'countries' => [
'US',
'GB'],
'result' => [
147 'three_d_secure' => [
152 [
'verify' =>
true,
'amount' => 40,
'countryId' =>
'US',
'countries' => [],
'result' => []],
153 [
'verify' =>
false,
'amount' => 40,
'countryId' =>
'US',
'countries' => [],
'result' => []],
154 [
'verify' =>
false,
'amount' => 20,
'countryId' =>
'US',
'countries' => [],
'result' => []],
155 [
'verify' =>
true,
'amount' => 20,
'countryId' =>
'CA',
'countries' => [
'US',
'GB'],
'result' => []],
164 private function initOrderMock()
166 $this->billingAddressMock = $this->getMockBuilder(AddressAdapter::class)
167 ->disableOriginalConstructor()
168 ->setMethods([
'getCountryId'])
171 $this->orderMock = $this->getMockBuilder(OrderAdapter::class)
172 ->disableOriginalConstructor()
173 ->setMethods([
'getBillingAddress',
'getStoreId'])
176 $this->orderMock->expects(static::any())
177 ->method(
'getBillingAddress')
178 ->willReturn($this->billingAddressMock);
179 $this->orderMock->method(
'getStoreId')
180 ->willReturn($this->storeId);
testBuild($verify, $thresholdAmount, $countryId, array $countries, array $expected)