33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare (strict_types=1 );
7+
68namespace tests \unit \Magento \FunctionalTestFramework \Test \Util ;
79
8- use AspectMock \Test as AspectMock ;
910use Magento \FunctionalTestingFramework \DataGenerator \Handlers \DataObjectHandler ;
1011use Magento \FunctionalTestingFramework \DataGenerator \Objects \EntityDataObject ;
1112use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
1213use Magento \FunctionalTestingFramework \Exceptions \XmlException ;
1314use Magento \FunctionalTestingFramework \Test \Objects \ActionObject ;
1415use Magento \FunctionalTestingFramework \Test \Util \ActionMergeUtil ;
1516use Magento \FunctionalTestingFramework \Test \Util \ActionObjectExtractor ;
17+ use ReflectionProperty ;
1618use tests \unit \Util \MagentoTestCase ;
1719use tests \unit \Util \TestLoggingUtil ;
1820
1921class ActionMergeUtilTest extends MagentoTestCase
2022{
2123 /**
22- * Before test functionality
24+ * Before test functionality.
25+ *
2326 * @return void
2427 */
25- public function setUp (): void
28+ protected function setUp (): void
2629 {
2730 TestLoggingUtil::getInstance ()->setMockLoggingUtil ();
2831 }
@@ -31,8 +34,10 @@ public function setUp(): void
3134 * Test to validate actions are properly ordered during a merge.
3235 *
3336 * @return void
37+ * @throws TestReferenceException
38+ * @throws XmlException
3439 */
35- public function testResolveActionStepOrdering ()
40+ public function testResolveActionStepOrdering (): void
3641 {
3742 $ actions = [];
3843 $ actionsLength = 11 ;
@@ -46,7 +51,6 @@ public function testResolveActionStepOrdering()
4651 $ stepKey = 'stepKey ' . $ i ;
4752 $ type = 'testType ' ;
4853 $ actionAttributes = [];
49-
5054 $ actions [] = new ActionObject ($ stepKey , $ type , $ actionAttributes );
5155 }
5256
@@ -93,8 +97,10 @@ public function testResolveActionStepOrdering()
9397 * Test to validate action steps properly resolve entity data references.
9498 *
9599 * @return void
100+ * @throws TestReferenceException
101+ * @throws XmlException
96102 */
97- public function testResolveActionStepEntityData ()
103+ public function testResolveActionStepEntityData (): void
98104 {
99105 $ dataObjectName = 'myObject ' ;
100106 $ dataObjectType = 'testObject ' ;
@@ -110,36 +116,35 @@ public function testResolveActionStepEntityData()
110116 $ mockDataObject = new EntityDataObject ($ dataObjectName , $ dataObjectType , $ mockData , null , null , null );
111117
112118 // 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 );
115127
116128 // Create test object and action object
117129 $ actionAttributes = [$ userInputKey => $ userInputValue ];
118130 $ actions [$ actionName ] = new ActionObject ($ actionName , $ actionType , $ actionAttributes );
119-
120131 $ this ->assertEquals ($ userInputValue , $ actions [$ actionName ]->getCustomActionAttributes ()[$ userInputKey ]);
121132
122133 $ mergeUtil = new ActionMergeUtil ("test " , "TestCase " );
123134 $ resolvedActions = $ mergeUtil ->resolveActionSteps ($ actions );
124-
125135 $ this ->assertEquals ($ dataFieldValue , $ resolvedActions [$ actionName ]->getCustomActionAttributes ()[$ userInputKey ]);
126136 }
127137
128138 /**
129139 * Verify that an XmlException is thrown when an action references a non-existant action.
130140 *
131- * @throws TestReferenceException
132- * @throws XmlException
133141 * @return void
134- */
135- /**
136142 * @throws TestReferenceException
137143 * @throws XmlException
138144 */
139- public function testNoActionException ()
145+ public function testNoActionException (): void
140146 {
141147 $ actionObjects = [];
142-
143148 $ actionObjects [] = new ActionObject ('actionKey1 ' , 'bogusType ' , []);
144149 $ actionObjects [] = new ActionObject (
145150 'actionKey2 ' ,
@@ -149,20 +154,19 @@ public function testNoActionException()
149154 ActionObject::MERGE_ACTION_ORDER_BEFORE
150155 );
151156
152- $ this ->expectException (\Magento \FunctionalTestingFramework \Exceptions \XmlException::class);
153-
157+ $ this ->expectException (XmlException::class);
154158 $ actionMergeUtil = new ActionMergeUtil ("actionMergeUtilTest " , "TestCase " );
155159 $ actionMergeUtil ->resolveActionSteps ($ actionObjects );
156160 }
157161
158162 /**
159163 * Verify that a <waitForPageLoad> action is added after actions that have a wait (timeout property).
160164 *
165+ * @return void
161166 * @throws TestReferenceException
162167 * @throws XmlException
163- * @return void
164168 */
165- public function testInsertWait ()
169+ public function testInsertWait (): void
166170 {
167171 $ actionObjectOne = new ActionObject ('actionKey1 ' , 'bogusType ' , []);
168172 $ actionObjectOne ->setTimeout (42 );
@@ -185,10 +189,11 @@ public function testInsertWait()
185189 /**
186190 * Verify that a <fillField> action is replaced by <fillSecretField> when secret _CREDS are referenced.
187191 *
192+ * @return void
188193 * @throws TestReferenceException
189194 * @throws XmlException
190195 */
191- public function testValidFillFieldSecretFunction ()
196+ public function testValidFillFieldSecretFunction (): void
192197 {
193198 $ actionObjectOne = new ActionObject (
194199 'actionKey1 ' ,
@@ -198,7 +203,6 @@ public function testValidFillFieldSecretFunction()
198203 $ actionObject = [$ actionObjectOne ];
199204
200205 $ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
201-
202206 $ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
203207
204208 $ expectedValue = new ActionObject (
@@ -212,10 +216,11 @@ public function testValidFillFieldSecretFunction()
212216 /**
213217 * Verify that a <magentoCLI> action uses <magentoCLI> when secret _CREDS are referenced.
214218 *
219+ * @return void
215220 * @throws TestReferenceException
216221 * @throws XmlException
217222 */
218- public function testValidMagentoCLISecretFunction ()
223+ public function testValidMagentoCLISecretFunction (): void
219224 {
220225 $ actionObjectOne = new ActionObject (
221226 'actionKey1 ' ,
@@ -225,7 +230,6 @@ public function testValidMagentoCLISecretFunction()
225230 $ actionObject = [$ actionObjectOne ];
226231
227232 $ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
228-
229233 $ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
230234
231235 $ expectedValue = new ActionObject (
@@ -239,10 +243,11 @@ public function testValidMagentoCLISecretFunction()
239243 /**
240244 * Verify that a <field> override in a <createData> action uses <field> when secret _CREDS are referenced.
241245 *
246+ * @return void
242247 * @throws TestReferenceException
243248 * @throws XmlException
244249 */
245- public function testValidCreateDataSecretFunction ()
250+ public function testValidCreateDataSecretFunction (): void
246251 {
247252 $ actionObjectOne = new ActionObject (
248253 'actionKey1 ' ,
@@ -252,7 +257,6 @@ public function testValidCreateDataSecretFunction()
252257 $ actionObject = [$ actionObjectOne ];
253258
254259 $ actionMergeUtil = new ActionMergeUtil ('actionMergeUtilTest ' , 'TestCase ' );
255-
256260 $ result = $ actionMergeUtil ->resolveActionSteps ($ actionObject );
257261
258262 $ expectedValue = new ActionObject (
@@ -266,10 +270,11 @@ public function testValidCreateDataSecretFunction()
266270 /**
267271 * Verify that a <click> action throws an exception when secret _CREDS are referenced.
268272 *
273+ * @return void
269274 * @throws TestReferenceException
270275 * @throws XmlException
271276 */
272- public function testInvalidSecretFunctions ()
277+ public function testInvalidSecretFunctions (): void
273278 {
274279 $ this ->expectException (TestReferenceException::class);
275280 $ this ->expectExceptionMessage (
@@ -288,7 +293,8 @@ public function testInvalidSecretFunctions()
288293 }
289294
290295 /**
291- * After class functionality
296+ * After class functionality.
297+ *
292298 * @return void
293299 */
294300 public static function tearDownAfterClass (): void
0 commit comments