@@ -191,6 +191,8 @@ public function testTimeoutFromElement()
191
191
192
192
/**
193
193
* {{PageObject.url}} should be replaced with someUrl.html
194
+ *
195
+ * @throws /Exception
194
196
*/
195
197
public function testResolveUrl ()
196
198
{
@@ -213,6 +215,40 @@ public function testResolveUrl()
213
215
$ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
214
216
}
215
217
218
+ /**
219
+ * {{PageObject}} should not be replaced and should elicit a warning in console
220
+ *
221
+ * @throws /Exception
222
+ */
223
+ public function testResolveUrlWithNoAttribute ()
224
+ {
225
+ // Set up mocks
226
+ $ actionObject = new ActionObject ('merge123 ' , 'amOnPage ' , [
227
+ 'url ' => '{{PageObject}} '
228
+ ]);
229
+ $ pageObject = new PageObject ('PageObject ' , '/replacement/url.html ' , 'Test ' , [], false , "test " );
230
+ $ pageObjectList = ["PageObject " => $ pageObject ];
231
+ $ instance = AspectMock::double (
232
+ PageObjectHandler::class,
233
+ ['getObject ' => $ pageObject , 'getAllObjects ' => $ pageObjectList ]
234
+ )->make (); // bypass the private constructor
235
+ AspectMock::double (PageObjectHandler::class, ['getInstance ' => $ instance ]);
236
+
237
+ // Expect this warning to get generated
238
+ $ this ->expectOutputString (
239
+ "WARNING: Page url attribute not found for {{PageObject}} and is required for amOnPage. " . PHP_EOL
240
+ );
241
+
242
+ // Call the method under test
243
+ $ actionObject ->resolveReferences ();
244
+
245
+ // Verify
246
+ $ expected = [
247
+ 'url ' => '{{PageObject}} '
248
+ ];
249
+ $ this ->assertEquals ($ expected , $ actionObject ->getCustomActionAttributes ());
250
+ }
251
+
216
252
/**
217
253
* {{PageObject.url(param)}} should be replaced
218
254
*/
0 commit comments