Skip to content

Commit 2e3073d

Browse files
authored
Merge pull request #4987 from magento-tsg/2.3-develop-com-pr4
[TSG-Commerce] Tests for 2.3 (pr4) (2.3-develop)
2 parents 7076b99 + 5d8d4e8 commit 2e3073d

File tree

38 files changed

+3234
-175
lines changed

38 files changed

+3234
-175
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\Attribute\DataProvider;
9+
10+
use Magento\TestFramework\Eav\Model\Attribute\DataProvider\AbstractBaseAttributeData;
11+
12+
/**
13+
* Product attribute data for attribute with input type media image.
14+
*/
15+
class MediaImage extends AbstractBaseAttributeData
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public function __construct()
21+
{
22+
parent::__construct();
23+
$this->defaultAttributePostData['used_for_sort_by'] = '0';
24+
}
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
public function getAttributeData(): array
30+
{
31+
$result = parent::getAttributeData();
32+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
33+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
34+
35+
return $result;
36+
}
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
public function getAttributeDataWithCheckArray(): array
42+
{
43+
$result = parent::getAttributeDataWithCheckArray();
44+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
45+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
46+
47+
return $result;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
protected function getFrontendInput(): string
54+
{
55+
return 'media_image';
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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\Attribute\DataProvider;
9+
10+
use Magento\TestFramework\Eav\Model\Attribute\DataProvider\AbstractBaseAttributeData;
11+
12+
/**
13+
* Product attribute data for attribute with input type weee.
14+
*/
15+
class Price extends AbstractBaseAttributeData
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public function __construct()
21+
{
22+
parent::__construct();
23+
$this->defaultAttributePostData['is_filterable'] = '0';
24+
$this->defaultAttributePostData['is_filterable_in_search'] = '0';
25+
$this->defaultAttributePostData['used_for_sort_by'] = '0';
26+
}
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
public function getAttributeData(): array
32+
{
33+
$result = parent::getAttributeData();
34+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
35+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
36+
37+
return $result;
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function getAttributeDataWithCheckArray(): array
44+
{
45+
$result = parent::getAttributeDataWithCheckArray();
46+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
47+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
48+
49+
return $result;
50+
}
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
protected function getFrontendInput(): string
56+
{
57+
return 'price';
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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\Eav\Model\Attribute\DataProvider;
9+
10+
/**
11+
* Base POST data for create attribute with options.
12+
*/
13+
abstract class AbstractAttributeDataWithOptions extends AbstractBaseAttributeData
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
public function __construct()
19+
{
20+
parent::__construct();
21+
$this->defaultAttributePostData['serialized_options_arr'] = $this->getOptionsDataArr();
22+
$this->defaultAttributePostData['is_filterable'] = '0';
23+
$this->defaultAttributePostData['is_filterable_in_search'] = '0';
24+
}
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
public function getAttributeData(): array
30+
{
31+
$result = parent::getAttributeData();
32+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
33+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
34+
35+
return $result;
36+
}
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
public function getAttributeDataWithErrorMessage(): array
42+
{
43+
$wrongSerializeMessage = 'The attribute couldn\'t be saved due to an error. Verify your information and ';
44+
$wrongSerializeMessage .= 'try again. If the error persists, please try again later.';
45+
46+
return array_replace_recursive(
47+
parent::getAttributeDataWithErrorMessage(),
48+
[
49+
"{$this->getFrontendInput()}_with_wrong_serialized_options" => [
50+
array_merge(
51+
$this->defaultAttributePostData,
52+
[
53+
'serialized_options_arr' => [],
54+
'serialized_options' => '?.\\//',
55+
]
56+
),
57+
(string)__($wrongSerializeMessage)
58+
],
59+
]
60+
);
61+
}
62+
63+
/**
64+
* @inheritdoc
65+
*/
66+
public function getAttributeDataWithCheckArray(): array
67+
{
68+
$result = parent::getAttributeDataWithCheckArray();
69+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
70+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
71+
72+
return $result;
73+
}
74+
75+
/**
76+
* Return attribute options data.
77+
*
78+
* @return array
79+
*/
80+
protected function getOptionsDataArr(): array
81+
{
82+
return [
83+
[
84+
'option' => [
85+
'order' => [
86+
'option_0' => '1',
87+
],
88+
'value' => [
89+
'option_0' => [
90+
'Admin value 1',
91+
'Default store view value 1',
92+
],
93+
],
94+
'delete' => [
95+
'option_0' => '',
96+
],
97+
],
98+
],
99+
[
100+
'option' => [
101+
'order' => [
102+
'option_1' => '2',
103+
],
104+
'value' => [
105+
'option_1' => [
106+
'Admin value 2',
107+
'Default store view value 2',
108+
],
109+
],
110+
'delete' => [
111+
'option_1' => '',
112+
],
113+
],
114+
],
115+
];
116+
}
117+
}

0 commit comments

Comments
 (0)