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