File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
src/Magento/FunctionalTestingFramework/Test/Objects Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,14 @@ private function resolveUrlReference()
404
404
$ url = $ this ->actionAttributes [ActionObject::ACTION_ATTRIBUTE_URL ];
405
405
406
406
$ replacement = $ this ->findAndReplaceReferences (PageObjectHandler::getInstance (), $ url );
407
+
408
+ $ missingReferences = $ this ->getMissingReferences ($ replacement );
409
+ if (!empty ($ missingReferences )) {
410
+ throw new TestReferenceException (
411
+ sprintf ('Can not resolve replacements: "%s" ' , implode ('", " ' , $ missingReferences ))
412
+ );
413
+ }
414
+
407
415
if ($ replacement ) {
408
416
$ this ->resolvedCustomAttributes [ActionObject::ACTION_ATTRIBUTE_URL ] = $ replacement ;
409
417
$ allPages = PageObjectHandler::getInstance ()->getAllObjects ();
@@ -417,6 +425,20 @@ private function resolveUrlReference()
417
425
}
418
426
}
419
427
428
+ /**
429
+ * Returns array of missing references
430
+ *
431
+ * @param $replacement
432
+ * @return array
433
+ */
434
+ private function getMissingReferences ($ replacement ): array
435
+ {
436
+ $ mustachePattern = '/({{[\w]+}})|({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/ ' ;
437
+ preg_match_all ($ mustachePattern , $ replacement , $ matches );
438
+
439
+ return array_filter ($ matches [1 ], function ($ match ) { return false === strpos ($ match , '_ENV. ' ); });
440
+ }
441
+
420
442
/**
421
443
* Look up the value for EntityDataObjectName.Key and set it as the corresponding attribute in the resolved custom
422
444
* attributes.
You can’t perform that action at this time.
0 commit comments