15 use PHPUnit_Framework_MockObject_MockObject as MockObject;
25 private $attributeDataProvider;
30 private $attributeMapper;
35 private $attributeMerger;
45 private $layoutProcessor;
50 private $storeManager;
54 $this->attributeDataProvider = $this->getMockBuilder(AttributeMetadataDataProvider::class)
55 ->disableOriginalConstructor()
56 ->setMethods([
'loadAttributesCollection'])
59 $this->attributeMapper = $this->getMockBuilder(AttributeMapper::class)
60 ->disableOriginalConstructor()
64 $this->attributeMerger = $this->getMockBuilder(AttributeMerger::class)
65 ->disableOriginalConstructor()
66 ->setMethods([
'merge'])
69 $this->dataHelper = $this->getMockBuilder(Data::class)
70 ->disableOriginalConstructor()
71 ->setMethods([
'isDisplayBillingOnPaymentMethodAvailable'])
74 $options = $this->getMockBuilder(Options::class)
75 ->disableOriginalConstructor()
78 $shippingConfig = $this->getMockBuilder(\
Magento\Shipping\Model\Config::class)
79 ->disableOriginalConstructor()
82 $this->storeManager = $this->createMock(\
Magento\Store\Model\StoreManagerInterface::class);
85 $this->attributeDataProvider,
86 $this->attributeMapper,
87 $this->attributeMerger,
100 $jsLayout = $this->getLayoutData();
102 $this->attributeDataProvider->expects(static::once())
103 ->method(
'loadAttributesCollection')
106 $this->dataHelper->expects(static::once())
107 ->method(
'isDisplayBillingOnPaymentMethodAvailable')
110 $this->attributeMerger->expects(static::exactly(2))
113 [
'payment1_1' => $this->getBillingComponent(
'payment1_1')],
114 [
'payment2_1' => $this->getBillingComponent(
'payment2_1')],
117 $actual = $this->layoutProcessor->process($jsLayout);
119 static::assertArrayHasKey(
121 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children']
122 [
'payment'][
'children'][
'payments-list'][
'children']
124 static::assertArrayHasKey(
126 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children']
127 [
'payment'][
'children'][
'payments-list'][
'children']
129 static::assertArrayNotHasKey(
131 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children']
132 [
'payment'][
'children'][
'payments-list'][
'children']
134 static::assertArrayHasKey(
136 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step']
137 [
'children'][
'payment'][
'children']
140 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step']
141 [
'children'][
'payment'][
'children'][
'afterMethods'][
'children']
150 $jsLayout = $this->getLayoutData();
152 $this->attributeDataProvider->expects(static::once())
153 ->method(
'loadAttributesCollection')
156 $this->dataHelper->expects(static::once())
157 ->method(
'isDisplayBillingOnPaymentMethodAvailable')
160 $this->attributeMerger->expects(static::once())
162 ->willReturn($this->getBillingComponent(
'shared'));
164 $actual = $this->layoutProcessor->process($jsLayout);
167 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children']
168 [
'payment'][
'children'][
'payments-list'][
'children']
171 static::assertNotEmpty(
172 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children']
173 [
'payment'][
'children'][
'afterMethods'][
'children']
175 static::assertArrayHasKey(
176 'billing-address-form',
177 $actual[
'components'][
'checkout'][
'children'][
'steps'][
'children'][
'billing-step'][
'children'][
'payment']
178 [
'children'][
'afterMethods'][
'children']
186 private function getLayoutData()
203 'isBillingAddressRequired' => true
210 'isBillingAddressRequired' => true
213 'isBillingAddressRequired' =>
false 236 private function getBillingComponent($paymentCode)
246 'component' =>
'Magento_Ui/js/form/element/region',
248 'template' =>
'ui/form/field',
249 'elementTmpl' =>
'ui/form/element/select',
250 'customEntry' =>
'billingAddress' . $paymentCode .
'.region',
253 'required-entry' =>
true,
256 'target' =>
'${ $.provider }:${ $.parentScope }.country_id',
257 'field' =>
'country_id',
261 'component' =>
'Magento_Ui/js/form/element/post-code',
263 'required-entry' =>
true,
268 'min_text_length' => 0,
273 'min_text_length' => 0,
279 'description' => (
'For delivery questions.'),
testProcessWithBillingAddressOnPaymentPage()