7
7
8
8
namespace Magento \Catalog \Test \Unit \Controller \Adminhtml \Product \Attribute ;
9
9
10
+ use Magento \Backend \Model \Session ;
11
+ use Magento \Backend \Model \View \Result \Redirect as ResultRedirect ;
10
12
use Magento \Catalog \Api \Data \ProductAttributeInterface ;
11
13
use Magento \Catalog \Controller \Adminhtml \Product \Attribute \Save ;
12
- use Magento \Eav \Model \Validator \Attribute \Code as AttributeCodeValidator ;
13
- use Magento \Framework \Serialize \Serializer \FormData ;
14
- use Magento \Catalog \Test \Unit \Controller \Adminhtml \Product \AttributeTest ;
15
- use Magento \Catalog \Model \Product \AttributeSet \BuildFactory ;
14
+ use Magento \Catalog \Helper \Product as ProductHelper ;
15
+ use Magento \Catalog \Model \Product \Attribute \Frontend \Inputtype \Presentation ;
16
16
use Magento \Catalog \Model \Product \AttributeSet \Build ;
17
+ use Magento \Catalog \Model \Product \AttributeSet \BuildFactory ;
17
18
use Magento \Catalog \Model \ResourceModel \Eav \AttributeFactory ;
19
+ use Magento \Catalog \Test \Unit \Controller \Adminhtml \Product \AttributeTest ;
18
20
use Magento \Eav \Api \Data \AttributeSetInterface ;
21
+ use Magento \Eav \Model \Adminhtml \System \Config \Source \Inputtype \Validator as InputTypeValidator ;
19
22
use Magento \Eav \Model \Adminhtml \System \Config \Source \Inputtype \ValidatorFactory ;
20
23
use Magento \Eav \Model \ResourceModel \Entity \Attribute \Group \CollectionFactory ;
24
+ use Magento \Eav \Model \Validator \Attribute \Code as AttributeCodeValidator ;
21
25
use Magento \Framework \Controller \ResultFactory ;
26
+ use Magento \Framework \Exception \NotFoundException ;
22
27
use Magento \Framework \Filter \FilterManager ;
23
- use Magento \Catalog \ Helper \ Product as ProductHelper ;
28
+ use Magento \Framework \ Serialize \ Serializer \ FormData ;
24
29
use Magento \Framework \View \Element \Messages ;
25
30
use Magento \Framework \View \LayoutFactory ;
26
- use Magento \Backend \Model \View \Result \Redirect as ResultRedirect ;
27
- use Magento \Eav \Model \Adminhtml \System \Config \Source \Inputtype \Validator as InputTypeValidator ;
28
31
use Magento \Framework \View \LayoutInterface ;
32
+ use PHPUnit \Framework \MockObject \MockObject ;
29
33
30
34
/**
31
35
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
36
+ * @SuppressWarnings(PHPMD.TooManyFields)
32
37
*/
33
38
class SaveTest extends AttributeTest
34
39
{
35
40
/**
36
41
* @var BuildFactory|MockObject
37
42
*/
38
- protected $ buildFactoryMock ;
43
+ private $ buildFactoryMock ;
39
44
40
45
/**
41
46
* @var FilterManager|MockObject
42
47
*/
43
- protected $ filterManagerMock ;
48
+ private $ filterManagerMock ;
44
49
45
50
/**
46
51
* @var ProductHelper|MockObject
47
52
*/
48
- protected $ productHelperMock ;
53
+ private $ productHelperMock ;
49
54
50
55
/**
51
56
* @var AttributeFactory|MockObject
52
57
*/
53
- protected $ attributeFactoryMock ;
58
+ private $ attributeFactoryMock ;
54
59
55
60
/**
56
61
* @var ValidatorFactory|MockObject
57
62
*/
58
- protected $ validatorFactoryMock ;
63
+ private $ validatorFactoryMock ;
59
64
60
65
/**
61
66
* @var CollectionFactory|MockObject
62
67
*/
63
- protected $ groupCollectionFactoryMock ;
68
+ private $ groupCollectionFactoryMock ;
64
69
65
70
/**
66
71
* @var LayoutFactory|MockObject
67
72
*/
68
- protected $ layoutFactoryMock ;
73
+ private $ layoutFactoryMock ;
69
74
70
75
/**
71
76
* @var ResultRedirect|MockObject
72
77
*/
73
- protected $ redirectMock ;
78
+ private $ redirectMock ;
74
79
75
80
/**
76
- * @var AttributeSet |MockObject
81
+ * @var AttributeSetInterface |MockObject
77
82
*/
78
- protected $ attributeSetMock ;
83
+ private $ attributeSetMock ;
79
84
80
85
/**
81
86
* @var Build|MockObject
82
87
*/
83
- protected $ builderMock ;
88
+ private $ builderMock ;
84
89
85
90
/**
86
91
* @var InputTypeValidator|MockObject
87
92
*/
88
- protected $ inputTypeValidatorMock ;
93
+ private $ inputTypeValidatorMock ;
89
94
90
95
/**
91
96
* @var FormData|MockObject
92
97
*/
93
- protected $ formDataSerializerMock ;
98
+ private $ formDataSerializerMock ;
94
99
95
100
/**
96
101
* @var ProductAttributeInterface|MockObject
97
102
*/
98
- protected $ productAttributeMock ;
103
+ private $ productAttributeMock ;
99
104
100
105
/**
101
- * @var Presentation |MockObject
106
+ * @var AttributeCodeValidator |MockObject
102
107
*/
103
- private $ formDataSerializerMock ;
108
+ private $ attributeCodeValidatorMock ;
104
109
105
110
/**
106
- * @var ProductAttributeInterface|\PHPUnit_Framework_MockObject_MockObject
111
+ * @var Presentation|MockObject
107
112
*/
108
- private $ productAttributeMock ;
113
+ private $ presentationMock ;
109
114
110
115
/**
111
- * @var AttributeCodeValidator |MockObject
116
+ * @var Session |MockObject
112
117
*/
113
- private $ attributeCodeValidatorMock ;
118
+
119
+ private $ sessionMock ;
114
120
115
121
protected function setUp (): void
116
122
{
@@ -129,12 +135,6 @@ protected function setUp(): void
129
135
->setMethods (['create ' ])
130
136
->disableOriginalConstructor ()
131
137
->getMock ();
132
- $ this ->filterManagerMock = $ this ->getMockBuilder (FilterManager::class)
133
- ->disableOriginalConstructor ()
134
- ->getMock ();
135
- $ this ->productHelperMock = $ this ->getMockBuilder (ProductHelper::class)
136
- ->disableOriginalConstructor ()
137
- ->getMock ();
138
138
$ this ->attributeFactoryMock = $ this ->getMockBuilder (AttributeFactory::class)
139
139
->setMethods (['create ' ])
140
140
->disableOriginalConstructor ()
@@ -147,28 +147,10 @@ protected function setUp(): void
147
147
->setMethods (['create ' ])
148
148
->disableOriginalConstructor ()
149
149
->getMock ();
150
- $ this ->layoutFactoryMock = $ this ->getMockBuilder (LayoutFactory::class)
151
- ->disableOriginalConstructor ()
152
- ->getMock ();
153
150
$ this ->redirectMock = $ this ->getMockBuilder (ResultRedirect::class)
154
151
->setMethods (['setData ' , 'setPath ' ])
155
152
->disableOriginalConstructor ()
156
153
->getMock ();
157
- $ this ->attributeSetMock = $ this ->getMockBuilder (AttributeSetInterface::class)
158
- ->disableOriginalConstructor ()
159
- ->getMock ();
160
- $ this ->builderMock = $ this ->getMockBuilder (Build::class)
161
- ->disableOriginalConstructor ()
162
- ->getMock ();
163
- $ this ->inputTypeValidatorMock = $ this ->getMockBuilder (InputTypeValidator::class)
164
- ->disableOriginalConstructor ()
165
- ->getMock ();
166
- $ this ->formDataSerializerMock = $ this ->getMockBuilder (FormData::class)
167
- ->disableOriginalConstructor ()
168
- ->getMock ();
169
- $ this ->attributeCodeValidatorMock = $ this ->getMockBuilder (AttributeCodeValidator::class)
170
- ->disableOriginalConstructor ()
171
- ->getMock ();
172
154
$ this ->productAttributeMock = $ this ->getMockBuilder (ProductAttributeInterface::class)
173
155
->setMethods (
174
156
[
0 commit comments