Skip to content

Commit 2aab3f9

Browse files
merge magento/2.3-develop into magento-tsg/2.3-develop-pr84
2 parents 7250ffc + e49d6b7 commit 2aab3f9

File tree

26 files changed

+2576
-115
lines changed

26 files changed

+2576
-115
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
9+
10+
/**
11+
* Base custom options data provider.
12+
*/
13+
abstract class AbstractBase
14+
{
15+
/**
16+
* Return data for create options for all cases.
17+
*
18+
* @return array
19+
*/
20+
public function getDataForCreateOptions(): array
21+
{
22+
return [
23+
"type_{$this->getType()}_title" => [
24+
[
25+
'record_id' => 0,
26+
'sort_order' => 1,
27+
'is_require' => 1,
28+
'sku' => 'test-option-title-1',
29+
'max_characters' => 50,
30+
'title' => 'Test option title 1',
31+
'type' => $this->getType(),
32+
'price' => 10,
33+
'price_type' => 'fixed',
34+
],
35+
],
36+
"type_{$this->getType()}_required_options" => [
37+
[
38+
'record_id' => 0,
39+
'sort_order' => 1,
40+
'is_require' => 1,
41+
'sku' => 'test-option-title-1',
42+
'max_characters' => 50,
43+
'title' => 'Test option title 1',
44+
'type' => $this->getType(),
45+
'price' => 10,
46+
'price_type' => 'fixed',
47+
],
48+
],
49+
"type_{$this->getType()}_not_required_options" => [
50+
[
51+
'record_id' => 0,
52+
'sort_order' => 1,
53+
'is_require' => 0,
54+
'sku' => 'test-option-title-1',
55+
'max_characters' => 50,
56+
'title' => 'Test option title 1',
57+
'type' => $this->getType(),
58+
'price' => 10,
59+
'price_type' => 'fixed',
60+
],
61+
],
62+
"type_{$this->getType()}_options_with_fixed_price" => [
63+
[
64+
'record_id' => 0,
65+
'sort_order' => 1,
66+
'is_require' => 1,
67+
'sku' => 'test-option-title-1',
68+
'max_characters' => 50,
69+
'title' => 'Test option title 1',
70+
'type' => $this->getType(),
71+
'price' => 10,
72+
'price_type' => 'fixed',
73+
],
74+
],
75+
"type_{$this->getType()}_options_with_percent_price" => [
76+
[
77+
'record_id' => 0,
78+
'sort_order' => 1,
79+
'is_require' => 1,
80+
'sku' => 'test-option-title-1',
81+
'max_characters' => 50,
82+
'title' => 'Test option title 1',
83+
'type' => $this->getType(),
84+
'price' => 10,
85+
'price_type' => 'percent',
86+
],
87+
],
88+
"type_{$this->getType()}_price" => [
89+
[
90+
'record_id' => 0,
91+
'sort_order' => 1,
92+
'is_require' => 1,
93+
'sku' => 'test-option-title-1',
94+
'max_characters' => 50,
95+
'title' => 'Test option title 1',
96+
'type' => $this->getType(),
97+
'price' => 22,
98+
'price_type' => 'percent',
99+
],
100+
],
101+
"type_{$this->getType()}_sku" => [
102+
[
103+
'record_id' => 0,
104+
'sort_order' => 1,
105+
'is_require' => 1,
106+
'sku' => 'test-option-title-1',
107+
'max_characters' => 50,
108+
'title' => 'Test option title 1',
109+
'type' => $this->getType(),
110+
'price' => 22,
111+
'price_type' => 'percent',
112+
],
113+
],
114+
];
115+
}
116+
117+
/**
118+
* Return data for create options for all cases.
119+
*
120+
* @return array
121+
*/
122+
public function getDataForUpdateOptions(): array
123+
{
124+
return array_merge_recursive(
125+
$this->getDataForCreateOptions(),
126+
[
127+
"type_{$this->getType()}_title" => [
128+
[
129+
'title' => 'Test updated option title',
130+
]
131+
],
132+
"type_{$this->getType()}_required_options" => [
133+
[
134+
'is_require' => 0,
135+
],
136+
],
137+
"type_{$this->getType()}_not_required_options" => [
138+
[
139+
'is_require' => 1,
140+
],
141+
],
142+
"type_{$this->getType()}_options_with_fixed_price" => [
143+
[
144+
'price_type' => 'percent',
145+
],
146+
],
147+
"type_{$this->getType()}_options_with_percent_price" => [
148+
[
149+
'price_type' => 'fixed',
150+
],
151+
],
152+
"type_{$this->getType()}_price" => [
153+
[
154+
'price' => 60,
155+
],
156+
],
157+
"type_{$this->getType()}_sku" => [
158+
[
159+
'sku' => 'Updated option sku',
160+
],
161+
],
162+
]
163+
);
164+
}
165+
166+
/**
167+
* Return option type.
168+
*
169+
* @return string
170+
*/
171+
abstract protected function getType(): string;
172+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
9+
10+
use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
11+
12+
/**
13+
* Abstract data provider for options from select group.
14+
*/
15+
abstract class AbstractSelect extends AbstractBase
16+
{
17+
/**
18+
* @inheritdoc
19+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
20+
*/
21+
public function getDataForCreateOptions(): array
22+
{
23+
return [
24+
"type_{$this->getType()}_title" => [
25+
[
26+
'record_id' => 0,
27+
'sort_order' => 1,
28+
'is_require' => 1,
29+
'title' => 'Test option title 1',
30+
'type' => $this->getType(),
31+
],
32+
[
33+
'record_id' => 0,
34+
'title' => 'Test option 1 value 1',
35+
'price' => 10,
36+
'price_type' => 'fixed',
37+
'sku' => 'test-option-1-value-1',
38+
'sort_order' => 1,
39+
],
40+
],
41+
"type_{$this->getType()}_required_options" => [
42+
[
43+
'record_id' => 0,
44+
'sort_order' => 1,
45+
'is_require' => 1,
46+
'title' => 'Test option title 1',
47+
'type' => $this->getType(),
48+
],
49+
[
50+
'record_id' => 0,
51+
'title' => 'Test option 1 value 1',
52+
'price' => 10,
53+
'price_type' => 'fixed',
54+
'sku' => 'test-option-1-value-1',
55+
'sort_order' => 1,
56+
],
57+
],
58+
"type_{$this->getType()}_not_required_options" => [
59+
[
60+
'record_id' => 0,
61+
'sort_order' => 1,
62+
'is_require' => 0,
63+
'title' => 'Test option title 1',
64+
'type' => $this->getType(),
65+
],
66+
[
67+
'record_id' => 0,
68+
'title' => 'Test option 1 value 1',
69+
'price' => 10,
70+
'price_type' => 'fixed',
71+
'sku' => 'test-option-1-value-1',
72+
'sort_order' => 1,
73+
],
74+
],
75+
"type_{$this->getType()}_options_with_fixed_price" => [
76+
[
77+
'record_id' => 0,
78+
'sort_order' => 1,
79+
'is_require' => 1,
80+
'title' => 'Test option title 1',
81+
'type' => $this->getType(),
82+
],
83+
[
84+
'record_id' => 0,
85+
'title' => 'Test option 1 value 1',
86+
'price' => 10,
87+
'price_type' => 'fixed',
88+
'sku' => 'test-option-1-value-1',
89+
'sort_order' => 1,
90+
],
91+
],
92+
"type_{$this->getType()}_options_with_percent_price" => [
93+
[
94+
'record_id' => 0,
95+
'sort_order' => 1,
96+
'is_require' => 1,
97+
'title' => 'Test option title 1',
98+
'type' => $this->getType(),
99+
],
100+
[
101+
'record_id' => 0,
102+
'title' => 'Test option 1 value 1',
103+
'price' => 10,
104+
'price_type' => 'percent',
105+
'sku' => 'test-option-1-value-1',
106+
'sort_order' => 1,
107+
],
108+
],
109+
"type_{$this->getType()}_price" => [
110+
[
111+
'record_id' => 0,
112+
'sort_order' => 1,
113+
'is_require' => 1,
114+
'title' => 'Test option title 1',
115+
'type' => $this->getType(),
116+
],
117+
[
118+
'record_id' => 0,
119+
'title' => 'Test option 1 value 1',
120+
'price' => 22,
121+
'price_type' => 'fixed',
122+
'sku' => 'test-option-1-value-1',
123+
'sort_order' => 1,
124+
],
125+
],
126+
"type_{$this->getType()}_sku" => [
127+
[
128+
'record_id' => 0,
129+
'sort_order' => 1,
130+
'is_require' => 1,
131+
'title' => 'Test option title 1',
132+
'type' => $this->getType(),
133+
],
134+
[
135+
'record_id' => 0,
136+
'title' => 'Test option 1 value 1',
137+
'price' => 10,
138+
'price_type' => 'fixed',
139+
'sku' => 'test-option-1-value-1',
140+
'sort_order' => 1,
141+
],
142+
],
143+
];
144+
}
145+
146+
/**
147+
* @inheritdoc
148+
*/
149+
public function getDataForUpdateOptions(): array
150+
{
151+
return array_merge_recursive(
152+
$this->getDataForCreateOptions(),
153+
[
154+
"type_{$this->getType()}_title" => [
155+
[
156+
'title' => 'Updated test option title 1',
157+
],
158+
[],
159+
],
160+
"type_{$this->getType()}_required_options" => [
161+
[
162+
'is_require' => 0,
163+
],
164+
[],
165+
],
166+
"type_{$this->getType()}_not_required_options" => [
167+
[
168+
'is_require' => 1,
169+
],
170+
[],
171+
],
172+
"type_{$this->getType()}_options_with_fixed_price" => [
173+
[],
174+
[
175+
'price_type' => 'percent',
176+
],
177+
],
178+
"type_{$this->getType()}_options_with_percent_price" => [
179+
[],
180+
[
181+
'price_type' => 'fixed',
182+
],
183+
],
184+
"type_{$this->getType()}_price" => [
185+
[],
186+
[
187+
'price' => 666,
188+
],
189+
],
190+
"type_{$this->getType()}_sku" => [
191+
[],
192+
[
193+
'sku' => 'updated-test-option-1-value-1',
194+
],
195+
],
196+
]
197+
);
198+
}
199+
}

0 commit comments

Comments
 (0)