@@ -68,19 +68,125 @@ public function testResolveElementInSelector()
68
68
}
69
69
70
70
/**
71
- * {{Section.element(param)}} should be replaced
71
+ * {{Section.element(param)}} should replace correctly with 'stringLiterals'
72
72
*/
73
- public function testResolveSelectorWithOneParam ()
73
+ public function testResolveSelectorWithOneStringLiteral ()
74
74
{
75
- $ this ->markTestIncomplete ('TODO ' );
75
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
76
+ 'selector ' => "{{SectionObject.elementObject('stringliteral')}} " ,
77
+ 'userInput ' => 'Input '
78
+ ]);
79
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}} ' , null , '42 ' , true );
80
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
81
+ $ instance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
82
+ ->make (); // bypass the private constructor
83
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ instance ]);
84
+
85
+ // Call the method under test
86
+ $ actionObject ->resolveReferences ();
87
+
88
+ // Verify
89
+ $ expected = [
90
+ 'selector ' => '#stringliteral ' ,
91
+ 'userInput ' => 'Input '
92
+ ];
93
+ $ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
94
+ }
95
+
96
+ /**
97
+ * {{Section.element(param)}} should replace correctly with {{data.key}} references
98
+ */
99
+ public function testResolveSelectorWithOneDataReference ()
100
+ {
101
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
102
+ 'selector ' => "{{SectionObject.elementObject(dataObject.key)}} " ,
103
+ 'userInput ' => 'Input '
104
+ ]);
105
+
106
+ // Mock SectionHandler
107
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}} ' , null , '42 ' , true );
108
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
109
+ $ sectionInstance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
110
+ ->make (); // bypass the private constructor
111
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ sectionInstance ]);
112
+
113
+ // Mock DataHandler
114
+ $ dataObject = new EntityDataObject ('dataObject ' , 'dataType ' , ["key " => 'myValue ' ], null , null , null );
115
+ $ dataInstance = AspectMock::double (DataObjectHandler::class, ['getObject ' => $ dataObject ])
116
+ ->make ();
117
+ AspectMock::double (DataObjectHandler::class, ['getInstance ' => $ dataInstance ]);
118
+
119
+ // Call the method under test
120
+ $ actionObject ->resolveReferences ();
121
+
122
+ // Verify
123
+ $ expected = [
124
+ 'selector ' => '#myValue ' ,
125
+ 'userInput ' => 'Input '
126
+ ];
127
+ $ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
128
+ }
129
+
130
+ /**
131
+ * {{Section.element(param)}} should replace correctly with $data.key$ references
132
+ */
133
+ public function testResolveSelectorWithOnePersistedReference ()
134
+ {
135
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
136
+ 'selector ' => '{{SectionObject.elementObject($data.key$)}} ' ,
137
+ 'userInput ' => 'Input '
138
+ ]);
139
+
140
+ // Mock SectionHandler
141
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}} ' , null , '42 ' , true );
142
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
143
+ $ sectionInstance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
144
+ ->make (); // bypass the private constructor
145
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ sectionInstance ]);
146
+
147
+ // Call the method under test
148
+ $ actionObject ->resolveReferences ();
149
+
150
+ // Verify
151
+ $ expected = [
152
+ 'selector ' => '#$data.key$ ' ,
153
+ 'userInput ' => 'Input '
154
+ ];
155
+ $ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
76
156
}
77
157
78
158
/**
79
- * {{Section.element(param1,param2)}} should be replaced
159
+ * {{Section.element(param1,param2,param3 )}} should replace correctly with all 3 data types.
80
160
*/
81
161
public function testResolveSelectorWithManyParams ()
82
162
{
83
- $ this ->markTestIncomplete ('TODO ' );
163
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
164
+ 'selector ' => "{{SectionObject.elementObject('stringLiteral', data.key, \$data.key \$)}} " ,
165
+ 'userInput ' => 'Input '
166
+ ]);
167
+
168
+ // Mock SectionHandler
169
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}}[{{var2}}, {{var3}}] ' , null , '42 ' , true );
170
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
171
+ $ sectionInstance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
172
+ ->make (); // bypass the private constructor
173
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ sectionInstance ]);
174
+
175
+ // Mock DataHandler
176
+ $ dataObject = new EntityDataObject ('dataObject ' , 'dataType ' , ["key " => 'myValue ' ], null , null , null );
177
+ $ dataInstance = AspectMock::double (DataObjectHandler::class, ['getObject ' => $ dataObject ])
178
+ ->make ();
179
+ AspectMock::double (DataObjectHandler::class, ['getInstance ' => $ dataInstance ]);
180
+
181
+ // Call the method under test
182
+ $ actionObject ->resolveReferences ();
183
+
184
+ // Verify
185
+ $ expected = [
186
+ 'selector ' => '#stringLiteral[myValue, $data.key$] ' ,
187
+ 'userInput ' => 'Input '
188
+ ];
189
+ $ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
84
190
}
85
191
86
192
/**
@@ -173,19 +279,46 @@ public function testResolveDataInUserInput()
173
279
$ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
174
280
}
175
281
282
+
176
283
/**
177
- * $testScopeData$ (single dollar sign) should be replaced
284
+ * Action object should throw an exception if a reference to a parameterized selector has too few given args.
178
285
*/
179
- public function testTestScopeDataResolution ()
286
+ public function testTooFewArgumentException ()
180
287
{
181
- $ this ->markTestIncomplete ('TODO ' );
288
+ $ this ->expectException ('Magento\FunctionalTestingFramework\Exceptions\TestReferenceException ' );
289
+
290
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
291
+ 'selector ' => "{{SectionObject.elementObject('arg1')}} " ,
292
+ 'userInput ' => 'Input '
293
+ ]);
294
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}} {{var2}} ' , null , '42 ' , true );
295
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
296
+ $ instance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
297
+ ->make (); // bypass the private constructor
298
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ instance ]);
299
+
300
+ // Call the method under test
301
+ $ actionObject ->resolveReferences ();
182
302
}
183
303
184
304
/**
185
- * $$cestScopeData$$ (double dollar sign) should be replaced
305
+ * Action object should throw an exception if a reference to a parameterized selector has too many given args.
186
306
*/
187
- public function testCestScopeDataResolution ()
307
+ public function testTooManyArgumentException ()
188
308
{
189
- $ this ->markTestIncomplete ('TODO ' );
309
+ $ this ->expectException ('Magento\FunctionalTestingFramework\Exceptions\TestReferenceException ' );
310
+
311
+ $ actionObject = new ActionObject ('key123 ' , 'fillField ' , [
312
+ 'selector ' => "{{SectionObject.elementObject('arg1', 'arg2', 'arg3')}} " ,
313
+ 'userInput ' => 'Input '
314
+ ]);
315
+ $ elementObject = new ElementObject ('elementObject ' , 'button ' , '#{{var1}} ' , null , '42 ' , true );
316
+ $ sectionObject = new SectionObject ('SectionObject ' , ['elementObject ' => $ elementObject ]);
317
+ $ instance = AspectMock::double (SectionObjectHandler::class, ['getObject ' => $ sectionObject ])
318
+ ->make (); // bypass the private constructor
319
+ AspectMock::double (SectionObjectHandler::class, ['getInstance ' => $ instance ]);
320
+
321
+ // Call the method under test
322
+ $ actionObject ->resolveReferences ();
190
323
}
191
324
}
0 commit comments