3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace tests \unit \Magento \FunctionalTestFramework \Test \Util ;
7
9
8
- use AspectMock \Test as AspectMock ;
9
10
use Magento \FunctionalTestingFramework \DataGenerator \Handlers \DataObjectHandler ;
10
11
use Magento \FunctionalTestingFramework \DataGenerator \Objects \EntityDataObject ;
11
12
use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
12
13
use Magento \FunctionalTestingFramework \Exceptions \XmlException ;
13
14
use Magento \FunctionalTestingFramework \Test \Objects \ActionObject ;
14
15
use Magento \FunctionalTestingFramework \Test \Util \ActionMergeUtil ;
15
16
use Magento \FunctionalTestingFramework \Test \Util \ActionObjectExtractor ;
17
+ use ReflectionProperty ;
16
18
use tests \unit \Util \MagentoTestCase ;
17
19
use tests \unit \Util \TestLoggingUtil ;
18
20
19
21
class ActionMergeUtilTest extends MagentoTestCase
20
22
{
21
23
/**
22
- * Before test functionality
24
+ * Before test functionality.
25
+ *
23
26
* @return void
24
27
*/
25
- public function setUp (): void
28
+ protected function setUp (): void
26
29
{
27
30
TestLoggingUtil::getInstance ()->setMockLoggingUtil ();
28
31
}
@@ -31,8 +34,10 @@ public function setUp(): void
31
34
* Test to validate actions are properly ordered during a merge.
32
35
*
33
36
* @return void
37
+ * @throws TestReferenceException
38
+ * @throws XmlException
34
39
*/
35
- public function testResolveActionStepOrdering ()
40
+ public function testResolveActionStepOrdering (): void
36
41
{
37
42
$ actions = [];
38
43
$ actionsLength = 11 ;
@@ -46,7 +51,6 @@ public function testResolveActionStepOrdering()
46
51
$ stepKey = 'stepKey ' . $ i ;
47
52
$ type = 'testType ' ;
48
53
$ actionAttributes = [];
49
-
50
54
$ actions [] = new ActionObject ($ stepKey , $ type , $ actionAttributes );
51
55
}
52
56
@@ -93,8 +97,10 @@ public function testResolveActionStepOrdering()
93
97
* Test to validate action steps properly resolve entity data references.
94
98
*
95
99
* @return void
100
+ * @throws TestReferenceException
101
+ * @throws XmlException
96
102
*/
97
- public function testResolveActionStepEntityData ()
103
+ public function testResolveActionStepEntityData (): void
98
104
{
99
105
$ dataObjectName = 'myObject ' ;
100
106
$ dataObjectType = 'testObject ' ;
@@ -110,36 +116,35 @@ public function testResolveActionStepEntityData()
110
116
$ mockDataObject = new EntityDataObject ($ dataObjectName , $ dataObjectType , $ mockData , null , null , null );
111
117
112
118
// Set up mock DataObject Handler
113
- $ mockDOHInstance = AspectMock::double (DataObjectHandler::class, ['getObject ' => $ mockDataObject ])->make ();
114
- AspectMock::double (DataObjectHandler::class, ['getInstance ' => $ mockDOHInstance ]);
119
+ $ mockDOHInstance = $ this ->createMock (DataObjectHandler::class);
120
+ $ mockDOHInstance
121
+ ->expects ($ this ->any ())
122
+ ->method ('getObject ' )
123
+ ->willReturn ($ mockDataObject );
124
+ $ property = new ReflectionProperty (DataObjectHandler::class, 'INSTANCE ' );
125
+ $ property ->setAccessible (true );
126
+ $ property ->setValue ($ mockDOHInstance , $ mockDOHInstance );
115
127
116
128
// Create test object and action object
117
129
$ actionAttributes = [$ userInputKey => $ userInputValue ];
118
130
$ actions [$ actionName ] = new ActionObject ($ actionName , $ actionType , $ actionAttributes );
119
-
120
131
$ this ->assertEquals ($ userInputValue , $ actions [$ actionName ]->getCustomActionAttributes ()[$ userInputKey ]);
121
132
122
133
$ mergeUtil = new ActionMergeUtil ("test " , "TestCase " );
123
134
$ resolvedActions = $ mergeUtil ->resolveActionSteps ($ actions );
124
-
125
135
$ this ->assertEquals ($ dataFieldValue , $ resolvedActions [$ actionName ]->getCustomActionAttributes ()[$ userInputKey ]);
126
136
}
127
137
128
138
/**
129
139
* Verify that an XmlException is thrown when an action references a non-existant action.
130
140
*
131
- * @throws TestReferenceException
132
- * @throws XmlException
133
141
* @return void
134
- */
135
- /**
136
142
* @throws TestReferenceException
137
143
* @throws XmlException
138
144
*/
139
- public function testNoActionException ()
145
+ public function testNoActionException (): void
140
146
{
141
147
$ actionObjects = [];
142
-
143
148
$ actionObjects [] = new ActionObject ('actionKey1 ' , 'bogusType ' , []);
144
149
$ actionObjects [] = new ActionObject (
145
150
'actionKey2 ' ,
@@ -149,20 +154,19 @@ public function testNoActionException()
149
154
ActionObject::MERGE_ACTION_ORDER_BEFORE
150
155
);
151
156
152
- $ this ->expectException (\Magento \FunctionalTestingFramework \Exceptions \XmlException::class);
153
-
157
+ $ this ->expectException (XmlException::class);
154
158
$ actionMergeUtil = new ActionMergeUtil ("actionMergeUtilTest " , "TestCase " );
155
159
$ actionMergeUtil ->resolveActionSteps ($ actionObjects );
156
160
}
157
161
158
162
/**
159
163
* Verify that a <waitForPageLoad> action is added after actions that have a wait (timeout property).
160
164
*
165
+ * @return void
161
166
* @throws TestReferenceException
162
167
* @throws XmlException
163
- * @return void
164
168
*/
165
- public function testInsertWait ()
169
+ public function testInsertWait (): void
166
170
{
167
171
$ actionObjectOne = new ActionObject ('actionKey1 ' , 'bogusType ' , []);
168
172
$ actionObjectOne ->setTimeout (42 );
@@ -185,10 +189,11 @@ public function testInsertWait()
185
189
/**
186
190
* Verify that a <fillField> action is replaced by <fillSecretField> when secret _CREDS are referenced.
187
191
*
192
+ * @return void
188
193
* @throws TestReferenceException
189
194
* @throws XmlException
190
195
*/
191
- public function testValidFillFieldSecretFunction ()
196
+ public function testValidFillFieldSecretFunction (): void
192
197
{
193
198
$ actionObjectOne = new ActionObject (
194
199
'actionKey1 ' ,
@@ -198,7 +203,6 @@ public function testValidFillFieldSecretFunction()
198
203
$ actionObject = [$ actionObjectOne ];
199
204
200
205
$ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
201
-
202
206
$ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
203
207
204
208
$ expectedValue = new ActionObject (
@@ -212,10 +216,11 @@ public function testValidFillFieldSecretFunction()
212
216
/**
213
217
* Verify that a <magentoCLI> action uses <magentoCLI> when secret _CREDS are referenced.
214
218
*
219
+ * @return void
215
220
* @throws TestReferenceException
216
221
* @throws XmlException
217
222
*/
218
- public function testValidMagentoCLISecretFunction ()
223
+ public function testValidMagentoCLISecretFunction (): void
219
224
{
220
225
$ actionObjectOne = new ActionObject (
221
226
'actionKey1 ' ,
@@ -225,7 +230,6 @@ public function testValidMagentoCLISecretFunction()
225
230
$ actionObject = [$ actionObjectOne ];
226
231
227
232
$ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
228
-
229
233
$ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
230
234
231
235
$ expectedValue = new ActionObject (
@@ -239,10 +243,11 @@ public function testValidMagentoCLISecretFunction()
239
243
/**
240
244
* Verify that a <field> override in a <createData> action uses <field> when secret _CREDS are referenced.
241
245
*
246
+ * @return void
242
247
* @throws TestReferenceException
243
248
* @throws XmlException
244
249
*/
245
- public function testValidCreateDataSecretFunction ()
250
+ public function testValidCreateDataSecretFunction (): void
246
251
{
247
252
$ actionObjectOne = new ActionObject (
248
253
'actionKey1 ' ,
@@ -252,7 +257,6 @@ public function testValidCreateDataSecretFunction()
252
257
$ actionObject = [$ actionObjectOne ];
253
258
254
259
$ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
255
-
256
260
$ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
257
261
258
262
$ expectedValue = new ActionObject (
@@ -266,10 +270,11 @@ public function testValidCreateDataSecretFunction()
266
270
/**
267
271
* Verify that a <click> action throws an exception when secret _CREDS are referenced.
268
272
*
273
+ * @return void
269
274
* @throws TestReferenceException
270
275
* @throws XmlException
271
276
*/
272
- public function testInvalidSecretFunctions ()
277
+ public function testInvalidSecretFunctions (): void
273
278
{
274
279
$ this ->expectException (TestReferenceException::class);
275
280
$ this ->expectExceptionMessage (
@@ -288,7 +293,8 @@ public function testInvalidSecretFunctions()
288
293
}
289
294
290
295
/**
291
- * After class functionality
296
+ * After class functionality.
297
+ *
292
298
* @return void
293
299
*/
294
300
public static function tearDownAfterClass (): void
0 commit comments