diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt
index c500628b8..3452b8883 100644
--- a/dev/tests/verification/Resources/BasicFunctionalTest.txt
+++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt
@@ -75,6 +75,9 @@ class BasicFunctionalTestCest
$I->clickWithRightButton("#element .4123#element", 200, 300);
$I->closeTab();
$I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true);
+ $I->amGoingTo("delete entity that has the createDataKey: createKey1");
+ $createKey1->deleteEntity();
+ $I->deleteEntityByUrl("/V1/categories{$grabbedData}");
$I->dontSee("someInput", ".functionalTestSelector");
$I->dontSeeCheckboxIsChecked(".functionalTestSelector");
$I->dontSeeCookie("someInput");
diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml
index 77122d42f..70ba6299f 100644
--- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml
+++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml
@@ -38,6 +38,8 @@
+
+
diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
index 606437cd6..25bb65e07 100644
--- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
+++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
@@ -18,6 +18,7 @@
use Codeception\Exception\ModuleException;
use Codeception\Util\Uri;
use Codeception\Util\ActionSequence;
+use Magento\FunctionalTestingFramework\DataGenerator\Persist\Curl\WebapiExecutor;
use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport;
use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface;
use Magento\Setup\Exception;
@@ -437,7 +438,6 @@ public function scrollToTopOfPage()
*/
public function magentoCLI($command)
{
-
$apiURL = $this->config['url'] . getenv('MAGENTO_CLI_COMMAND_PATH');
$executor = new CurlTransport();
$executor->write($apiURL, [getenv('MAGENTO_CLI_COMMAND_PARAMETER') => $command], CurlInterface::POST, []);
@@ -446,6 +446,21 @@ public function magentoCLI($command)
return $response;
}
+ /**
+ * Runs DELETE request to delete a Magento entity against the url given.
+ * @param string $url
+ * @param int $storeCode
+ * @return string
+ */
+ public function deleteEntityByUrl($url, $storeCode = null)
+ {
+ $executor = new WebapiExecutor($storeCode);
+ $executor->write($url, [], CurlInterface::DELETE, []);
+ $response = $executor->read();
+ $executor->close();
+ return $response;
+ }
+
/**
* Conditional click for an area that should be visible
*
diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php
index 10cd77937..84f073c04 100644
--- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php
+++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php
@@ -7,6 +7,7 @@
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
+use Magento\FunctionalTestingFramework\Exceptions\XmlException;
use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface;
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
use Magento\FunctionalTestingFramework\Page\Objects\SectionObject;
@@ -34,6 +35,7 @@ class ActionObject
const ASSERTION_ATTRIBUTES = ["expectedResult" => "expected", "actualResult" => "actual"];
const ASSERTION_TYPE_ATTRIBUTE = "type";
const ASSERTION_VALUE_ATTRIBUTE = "value";
+ const DELETE_DATA_MUTUAL_EXCLUSIVE_ATTRIBUTES = ["url", "createDataKey"];
const EXTERNAL_URL_AREA_INVALID_ACTIONS = ['amOnPage'];
const MERGE_ACTION_ORDER_AFTER = 'after';
const MERGE_ACTION_ORDER_BEFORE = 'before';
@@ -229,6 +231,9 @@ public function resolveReferences()
$this->resolveSelectorReferenceAndTimeout();
$this->resolveUrlReference();
$this->resolveDataInputReferences();
+ if ($this->getType() == "deleteData") {
+ $this->validateMutuallyExclusiveAttributes(self::DELETE_DATA_MUTUAL_EXCLUSIVE_ATTRIBUTES);
+ }
}
}
@@ -496,6 +501,28 @@ private function findAndReplaceReferences($objectHandler, $inputString)
return $outputString;
}
+ /**
+ * Validates that the mutually exclusive attributes passed in don't all occur.
+ * @param array $attributes
+ * @return void
+ * @throws TestReferenceException
+ */
+ private function validateMutuallyExclusiveAttributes(array $attributes)
+ {
+ $matches = array_intersect($attributes, array_keys($this->getCustomActionAttributes()));
+ if (count($matches) > 1) {
+ throw new TestReferenceException(
+ "Actions of type '{$this->getType()}' must only contain one attribute of types '"
+ . implode("', '", $attributes) . "'"
+ );
+ } elseif (count($matches) == 0) {
+ throw new TestReferenceException(
+ "Actions of type '{$this->getType()}' must contain at least one attribute of types '"
+ . implode("', '", $attributes) . "'"
+ );
+ }
+ }
+
/**
* Validates the page objects area 'external' against a list of known incompatible types
*
diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd
index ad8ea9414..93c07b991 100644
--- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd
+++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd
@@ -76,7 +76,8 @@
-
+
+
diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
index a18d1e086..0d30717a2 100644
--- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
+++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
@@ -510,6 +510,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
$input = $this->addUniquenessFunctionCall($customActionAttributes['userInput']);
} elseif (isset($customActionAttributes['url'])) {
$input = $this->addUniquenessFunctionCall($customActionAttributes['url']);
+ $url = $this->addUniquenessFunctionCall($customActionAttributes['url']);
} elseif (isset($customActionAttributes['expectedValue'])) {
//For old Assert backwards Compatibility, remove when deprecating
$assertExpected = $this->addUniquenessFunctionCall($customActionAttributes['expectedValue']);
@@ -712,18 +713,37 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
$testSteps .= $createEntityFunctionCall;
break;
case "deleteData":
- $key = $customActionAttributes['createDataKey'];
- //Add an informative statement to help the user debug test runs
- $testSteps .= sprintf(
- "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n",
- $actor,
- $key
- );
+ if (isset($customActionAttributes['createDataKey'])) {
+ $key = $customActionAttributes['createDataKey'];
+ //Add an informative statement to help the user debug test runs
+ $testSteps .= sprintf(
+ "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n",
+ $actor,
+ $key
+ );
- if ($hookObject) {
- $testSteps .= sprintf("\t\t\$this->%s->deleteEntity();\n", $key);
+ if ($hookObject) {
+ $testSteps .= sprintf("\t\t\$this->%s->deleteEntity();\n", $key);
+ } else {
+ $testSteps .= sprintf("\t\t$%s->deleteEntity();\n", $key);
+ }
} else {
- $testSteps .= sprintf("\t\t$%s->deleteEntity();\n", $key);
+ $output = sprintf(
+ "\t\t$%s->deleteEntityByUrl(%s",
+ $actor,
+ $url
+ );
+ $storeCode = null;
+ if (isset($customActionAttributes["storeCode"])) {
+ $storeCode = $customActionAttributes["storeCode"];
+ $output .= sprintf(
+ ", %s",
+ $storeCode
+ );
+ }
+ $output .= ");\n";
+ $output = $this->resolveEnvReferences($output, [$url, $storeCode]);
+ $testSteps .= $this->resolveTestVariable($output, [$url, $storeCode], null);
}
break;
case "updateData":