Skip to content

Commit 61027d9

Browse files
committed
MQE-683: [Deprecation] Only use more nested assertion syntax
- Deprecated one-line syntax - added upgrade script
1 parent 76693d9 commit 61027d9

File tree

4 files changed

+127
-183
lines changed

4 files changed

+127
-183
lines changed

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class ActionObject
5656
"command",
5757
"html"
5858
];
59-
const OLD_ASSERTION_ATTRIBUTES = ["expected", "expectedType", "actual", "actualType"];
6059
const ASSERTION_ATTRIBUTES = ["expectedResult" => "expected", "actualResult" => "actual"];
6160
const ASSERTION_TYPE_ATTRIBUTE = "type";
6261
const ASSERTION_VALUE_ATTRIBUTE = "value";
@@ -303,33 +302,13 @@ public function resolveReferences()
303302
public function trimAssertionAttributes()
304303
{
305304
$actionAttributeKeys = array_keys($this->actionAttributes);
306-
307-
/** MQE-683 DEPRECATE OLD METHOD HERE
308-
* Checks if action has any of the old, single line attributes
309-
* Throws a warning and returns, assuming old syntax is used.
310-
*/
311-
$oldAttributes = array_intersect($actionAttributeKeys, ActionObject::OLD_ASSERTION_ATTRIBUTES);
312-
if (!empty($oldAttributes)) {
313-
$appConfig = MftfApplicationConfig::getConfig();
314-
if ($appConfig->getPhase() == MftfApplicationConfig::GENERATION_PHASE && $appConfig->verboseEnabled()) {
315-
LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation(
316-
"use of one line Assertion actions will be deprecated in MFTF 3.0.0, please use nested syntax",
317-
["action" => $this->type, "stepKey" => $this->stepKey],
318-
true
319-
);
320-
}
321-
return;
322-
}
323-
324305
$relevantKeys = array_keys(ActionObject::ASSERTION_ATTRIBUTES);
325306
$relevantAssertionAttributes = array_intersect($actionAttributeKeys, $relevantKeys);
326307

327308
if (empty($relevantAssertionAttributes)) {
328309
return;
329310
}
330311

331-
$this->validateAssertionSchema($relevantAssertionAttributes);
332-
333312
// Flatten nested Elements's type and value into key=>value entries
334313
foreach ($this->actionAttributes as $key => $subAttributes) {
335314
if (in_array($key, $relevantKeys)) {
@@ -343,32 +322,6 @@ public function trimAssertionAttributes()
343322
}
344323
}
345324

346-
/**
347-
* Validates that the given assertion attributes have valid schema according to nested assertion syntax.
348-
* @param array $attributes
349-
* @return void
350-
* @throws TestReferenceException
351-
*/
352-
private function validateAssertionSchema($attributes)
353-
{
354-
/** MQE-683 DEPRECATE OLD METHOD HERE
355-
* Unnecessary validation, only needed for backwards compatibility
356-
*/
357-
$singleChildTypes = ['assertEmpty', 'assertFalse', 'assertFileExists', 'assertFileNotExists',
358-
'assertIsEmpty', 'assertNotEmpty', 'assertNotNull', 'assertNull', 'assertTrue',
359-
'assertElementContainsAttribute'];
360-
361-
if (!in_array($this->type, $singleChildTypes)) {
362-
if (!in_array('expectedResult', $attributes)
363-
|| !in_array('actualResult', $attributes)) {
364-
throw new TestReferenceException(
365-
"{$this->type} must have both an expectedResult & actualResult defined (stepKey: {$this->stepKey})",
366-
["action" => $this->type, "stepKey" => $this->stepKey]
367-
);
368-
}
369-
}
370-
}
371-
372325
/**
373326
* Look up the selector for SomeSectionName.ElementName and set it as the selector attribute in the
374327
* resolved custom attributes. Also set the timeout value.

0 commit comments

Comments
 (0)