Skip to content

Commit fbea751

Browse files
committed
#22856: Integration tests fix.
1 parent 4ac980b commit fbea751

File tree

1 file changed

+73
-47
lines changed
  • dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type

1 file changed

+73
-47
lines changed

dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/File.php

Lines changed: 73 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
99

1010
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
11-
use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
11+
use Magento\Catalog\Model\Product\Option;
1212

1313
/**
1414
* Data provider for options from file group with type "file".
@@ -20,41 +20,44 @@ class File extends AbstractBase
2020
*/
2121
public function getDataForCreateOptions(): array
2222
{
23-
return array_merge_recursive(
24-
parent::getDataForCreateOptions(),
25-
[
26-
"type_{$this->getType()}_option_file_extension" => [
27-
[
28-
'record_id' => 0,
29-
'sort_order' => 1,
30-
'is_require' => 1,
31-
'sku' => 'test-option-title-1',
32-
'max_characters' => 30,
33-
'title' => 'Test option title 1',
34-
'type' => $this->getType(),
35-
'price' => 10,
36-
'price_type' => 'fixed',
37-
'file_extension' => 'gif',
38-
'image_size_x' => 10,
39-
'image_size_y' => 20,
23+
return $this->injectFileExtension(
24+
array_merge_recursive(
25+
parent::getDataForCreateOptions(),
26+
[
27+
"type_{$this->getType()}_option_file_extension" => [
28+
[
29+
'record_id' => 0,
30+
'sort_order' => 1,
31+
'is_require' => 1,
32+
'sku' => 'test-option-title-1',
33+
'max_characters' => 30,
34+
'title' => 'Test option title 1',
35+
'type' => $this->getType(),
36+
'price' => 10,
37+
'price_type' => 'fixed',
38+
'file_extension' => 'gif',
39+
'image_size_x' => 10,
40+
'image_size_y' => 20,
41+
],
4042
],
41-
],
42-
"type_{$this->getType()}_option_maximum_file_size" => [
43-
[
44-
'record_id' => 0,
45-
'sort_order' => 1,
46-
'is_require' => 1,
47-
'sku' => 'test-option-title-1',
48-
'title' => 'Test option title 1',
49-
'type' => $this->getType(),
50-
'price' => 10,
51-
'price_type' => 'fixed',
52-
'file_extension' => 'gif',
53-
'image_size_x' => 10,
54-
'image_size_y' => 20,
43+
"type_{$this->getType()}_option_maximum_file_size" => [
44+
[
45+
'record_id' => 0,
46+
'sort_order' => 1,
47+
'is_require' => 1,
48+
'sku' => 'test-option-title-1',
49+
'title' => 'Test option title 1',
50+
'type' => $this->getType(),
51+
'price' => 10,
52+
'price_type' => 'fixed',
53+
'file_extension' => 'gif',
54+
'image_size_x' => 10,
55+
'image_size_y' => 20,
56+
],
5557
],
56-
],
57-
]
58+
]
59+
),
60+
'png'
5861
);
5962
}
6063

@@ -63,21 +66,24 @@ public function getDataForCreateOptions(): array
6366
*/
6467
public function getDataForUpdateOptions(): array
6568
{
66-
return array_merge_recursive(
67-
parent::getDataForUpdateOptions(),
68-
[
69-
"type_{$this->getType()}_option_file_extension" => [
70-
[
71-
'file_extension' => 'jpg',
69+
return $this->injectFileExtension(
70+
array_merge_recursive(
71+
parent::getDataForUpdateOptions(),
72+
[
73+
"type_{$this->getType()}_option_file_extension" => [
74+
[
75+
'file_extension' => 'jpg',
76+
],
7277
],
73-
],
74-
"type_{$this->getType()}_option_maximum_file_size" => [
75-
[
76-
'image_size_x' => 300,
77-
'image_size_y' => 815,
78+
"type_{$this->getType()}_option_maximum_file_size" => [
79+
[
80+
'image_size_x' => 300,
81+
'image_size_y' => 815,
82+
],
7883
],
79-
],
80-
]
84+
]
85+
),
86+
''
8187
);
8288
}
8389

@@ -88,4 +94,24 @@ protected function getType(): string
8894
{
8995
return ProductCustomOptionInterface::OPTION_TYPE_FILE;
9096
}
97+
98+
/**
99+
* Add 'file_extension' value to each option.
100+
*
101+
* @param array $data
102+
* @param string $extension
103+
* @return array
104+
*/
105+
private function injectFileExtension(array $data, string $extension): array
106+
{
107+
foreach ($data as &$caseData) {
108+
foreach ($caseData as &$option) {
109+
if (!isset($option[Option::KEY_FILE_EXTENSION])) {
110+
$option[Option::KEY_FILE_EXTENSION] = $extension;
111+
}
112+
}
113+
}
114+
115+
return $data;
116+
}
91117
}

0 commit comments

Comments
 (0)