From 787897eb2cdd33e4f0565371476b2e0e40c794d2 Mon Sep 17 00:00:00 2001 From: Tom Reece Date: Fri, 6 Mar 2020 10:23:10 -0600 Subject: [PATCH 1/2] MQE-1799: Throw exception during generation when leaving out .url for amOnPage --- .../Page/Handlers/PageObjectHandler.php | 3 ++- .../FunctionalTestingFramework/Test/Objects/ActionObject.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php index c310b9bef..2542b2760 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php @@ -67,7 +67,8 @@ private function __construct() $module = $pageData[self::MODULE] ?? null; $sectionNames = array_keys($pageData[self::SECTION] ?? []); - $parameterized = $pageData[self::PARAMETERIZED] ?? false; + $urlContainsMustaches = strpos($url, "{{") !== false && strpos($url, "}}") !== false; + $parameterized = $pageData[self::PARAMETERIZED] ?? $urlContainsMustaches ?? false; $filename = $pageData[self::FILENAME] ?? null; $deprecated = $pageData[self::OBJ_DEPRECATED] ?? null; diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index f377e2fac..4d2d45d1f 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -420,7 +420,7 @@ private function resolveUrlReference() $allPages = PageObjectHandler::getInstance()->getAllObjects(); if ($replacement === $url && array_key_exists(trim($url, "{}"), $allPages) ) { - LoggingUtil::getInstance()->getLogger(ActionObject::class)->warning( + throw new TestReferenceException( "page url attribute not found and is required", ["action" => $this->type, "url" => $url, "stepKey" => $this->stepKey] ); From 34456fa0d49d838723b38cdba5be49086472919c Mon Sep 17 00:00:00 2001 From: Tom Reece Date: Fri, 6 Mar 2020 10:54:30 -0600 Subject: [PATCH 2/2] MQE-1799: Throw exception during generation when leaving out .url for amOnPage --- .../Test/Objects/ActionObjectTest.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php index 511c9748f..24a7e2ee6 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php @@ -233,6 +233,8 @@ public function testResolveUrl() */ public function testResolveUrlWithNoAttribute() { + $this->expectException(TestReferenceException::class); + // Set up mocks $actionObject = new ActionObject('merge123', 'amOnPage', [ 'url' => '{{PageObject}}' @@ -247,19 +249,6 @@ public function testResolveUrlWithNoAttribute() // Call the method under test $actionObject->resolveReferences(); - - // Expect this warning to get generated - TestLoggingUtil::getInstance()->validateMockLogStatement( - "warning", - "page url attribute not found and is required", - ['action' => $actionObject->getType(), 'url' => '{{PageObject}}', 'stepKey' => $actionObject->getStepKey()] - ); - - // Verify - $expected = [ - 'url' => '{{PageObject}}' - ]; - $this->assertEquals($expected, $actionObject->getCustomActionAttributes()); } /**