Skip to content

Commit 3166af8

Browse files
committed
MFTF deprecation notice attributes
1 parent e344c6f commit 3166af8

28 files changed

+452
-61
lines changed

dev/tests/functional/tests/MFTF/DevDocs/Section/ContentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="contentSection">
1212
<element name="pageIntro" type="text" selector=".page-intro"/>
13+
<element name="deprecatedPageIntro" type="text" selector=".page-intro-old" deprecated="New element was introduced. Please use 'contentSection.pageIntro'"/>
1314
</section>
1415
</sections>

dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121

2222
<!-- Open MFTF DevDocs Page -->
2323
<amOnPage stepKey="openMFTFDevDocPage" url="{{MFTFDocPage.url}}" />
24-
<see stepKey="verifyPageIntroText" selector="{{contentSection.pageIntro}}" userInput="Introduction to the Magento Functional Testing Framework" />
24+
<see stepKey="verifyPageIntroText" selector="{{contentSection.pageIntro}}" userInput="{{MessageData.message}}" />
2525
</test>
2626
</tests>

src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\FunctionalTestingFramework\Allure\Adapter;
77

8+
use Codeception\Event\TestEvent;
89
use Codeception\Step\Comment;
910
use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler;
1011
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;

src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@
77
namespace Magento\FunctionalTestingFramework\Codeception\Subscriber;
88

99
use Codeception\Event\StepEvent;
10+
use Codeception\Event\TestEvent;
1011
use Codeception\Lib\Console\Message;
1112
use Codeception\Step;
1213
use Codeception\Step\Comment;
1314
use Codeception\Test\Interfaces\ScenarioDriven;
1415
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
1516
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
17+
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1618
use Magento\FunctionalTestingFramework\Util\TestGenerator;
1719
use Symfony\Component\Console\Formatter\OutputFormatter;
1820

1921
class Console extends \Codeception\Subscriber\Console
2022
{
23+
/**
24+
* Regular expresion to find deprecated notices.
25+
*/
26+
const DEPRECATED_NOTICE = '/<li>(?<deprecatedMessage>.*?)<\/li>/m';
27+
2128
/**
2229
* Test files cache.
2330
*
@@ -53,6 +60,29 @@ public function __construct($extensionOptions = [], $options = [])
5360
parent::__construct($options);
5461
}
5562

63+
public function startTest(TestEvent $e)
64+
{
65+
$test = $e->getTest()->getTestClass();
66+
try {
67+
$testReflection = new \ReflectionClass($test);
68+
$isDeprecated = preg_match_all(self::DEPRECATED_NOTICE, $testReflection->getDocComment(), $match);
69+
if ($isDeprecated) {
70+
$this->message('DEPRECATION NOTICE(S): ')
71+
->style('debug')
72+
->writeln();
73+
foreach ($match['deprecatedMessage'] as $deprecatedMessage) {
74+
$this->message(' - ' . $deprecatedMessage)
75+
->style('debug')
76+
->writeln();
77+
}
78+
}
79+
} catch (\ReflectionException $e) {
80+
LoggingUtil::getInstance()->getLogger(self::class)->error($e->getMessage(), $e->getTrace());
81+
}
82+
83+
return parent::startTest($e);
84+
}
85+
5686
/**
5787
* Printing stepKey in before step action.
5888
*

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface;
1414
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
1515
use Magento\FunctionalTestingFramework\DataGenerator\Util\DataExtensionUtil;
16+
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
17+
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1618

1719
class DataObjectHandler implements ObjectHandlerInterface
1820
{
@@ -163,6 +165,14 @@ private function processParserOutput($parserOutput)
163165
$parentEntity = $rawEntity[self::_EXTENDS];
164166
}
165167

168+
if (array_key_exists('deprecated', $rawEntity)) {
169+
$deprecated = $rawEntity['deprecated'];
170+
LoggingUtil::getInstance()->getLogger(self::class)->deprecation(
171+
$deprecated,
172+
["dataName" => $filename, "deprecatedEntity" => $deprecated]
173+
);
174+
}
175+
166176
$entityDataObject = new EntityDataObject(
167177
$name,
168178
$type,
@@ -171,7 +181,8 @@ private function processParserOutput($parserOutput)
171181
$uniquenessData,
172182
$vars,
173183
$parentEntity,
174-
$filename
184+
$filename,
185+
$deprecated
175186
);
176187

177188
$entityDataObjects[$entityDataObject->getName()] = $entityDataObject;

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\FunctionalTestingFramework\DataGenerator\Util\OperationElementExtractor;
1212
use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface;
1313
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
14+
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1415

1516
class OperationDefinitionObjectHandler implements ObjectHandlerInterface
1617
{
@@ -145,6 +146,7 @@ private function initialize()
145146
$auth = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_AUTH] ?? null;
146147
$successRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_SUCCESS_REGEX] ?? null;
147148
$returnRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_REGEX] ?? null;
149+
$deprecated = $opDefArray['deprecated'] ?? null;
148150
$returnIndex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_INDEX] ?? 0;
149151
$contentType = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_CONTENT_TYPE][0]['value']
150152
?? null;
@@ -205,6 +207,13 @@ private function initialize()
205207
}
206208
}
207209

210+
if ($deprecated !== null) {
211+
LoggingUtil::getInstance()->getLogger(self::class)->deprecation(
212+
$deprecated,
213+
["operationName" => $dataDefName, "deprecatedOperation" => $deprecated]
214+
);
215+
}
216+
208217
$this->operationDefinitionObjects[$operation . $dataType] = new OperationDefinitionObject(
209218
$dataDefName,
210219
$operation,
@@ -219,7 +228,8 @@ private function initialize()
219228
$removeBackend,
220229
$successRegex,
221230
$returnRegex,
222-
$returnIndex
231+
$returnIndex,
232+
$deprecated
223233
);
224234
}
225235
}

src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,25 @@ class EntityDataObject
8080
*/
8181
private $filename;
8282

83+
/**
84+
* Deprecated message.
85+
*
86+
* @var string
87+
*/
88+
private $deprecated;
89+
8390
/**
8491
* Constructor
8592
*
86-
* @param string $name
87-
* @param string $type
93+
* @param string $name
94+
* @param string $type
8895
* @param string[] $data
8996
* @param string[] $linkedEntities
9097
* @param string[] $uniquenessData
9198
* @param string[] $vars
92-
* @param string $parentEntity
93-
* @param string $filename
99+
* @param string $parentEntity
100+
* @param string $filename
101+
* @param string|null $deprecated
94102
*/
95103
public function __construct(
96104
$name,
@@ -100,7 +108,8 @@ public function __construct(
100108
$uniquenessData,
101109
$vars = [],
102110
$parentEntity = null,
103-
$filename = null
111+
$filename = null,
112+
$deprecated = null
104113
) {
105114
$this->name = $name;
106115
$this->type = $type;
@@ -113,6 +122,17 @@ public function __construct(
113122
$this->vars = $vars;
114123
$this->parentEntity = $parentEntity;
115124
$this->filename = $filename;
125+
$this->deprecated = $deprecated;
126+
}
127+
128+
/**
129+
* Getter for the deprecated attr of the section.
130+
*
131+
* @return string
132+
*/
133+
public function getDeprecated()
134+
{
135+
return $this->deprecated;
116136
}
117137

118138
/**

src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class OperationDefinitionObject
117117
*/
118118
private $removeBackend;
119119

120+
/**
121+
* Deprecated message.
122+
*
123+
* @var string
124+
*/
125+
private $deprecated;
126+
120127
/**
121128
* OperationDefinitionObject constructor.
122129
* @param string $name
@@ -133,6 +140,7 @@ class OperationDefinitionObject
133140
* @param string $successRegex
134141
* @param string $returnRegex
135142
* @param string $returnIndex
143+
* @param string|null $deprecated
136144
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
137145
*/
138146
public function __construct(
@@ -149,7 +157,8 @@ public function __construct(
149157
$removeBackend,
150158
$successRegex = null,
151159
$returnRegex = null,
152-
$returnIndex = null
160+
$returnIndex = null,
161+
$deprecated = null
153162
) {
154163
$this->name = $name;
155164
$this->operation = $operation;
@@ -164,6 +173,7 @@ public function __construct(
164173
$this->returnRegex = $returnRegex;
165174
$this->returnIndex = $returnIndex;
166175
$this->removeBackend = $removeBackend;
176+
$this->deprecated = $deprecated;
167177
$this->apiUrl = null;
168178

169179
if (!empty($contentType)) {
@@ -176,6 +186,16 @@ public function __construct(
176186
$this->headers[] = self::HTTP_CONTENT_TYPE_HEADER . ': ' . $this->contentType;
177187
}
178188

189+
/**
190+
* Getter for the deprecated attr of the section
191+
*
192+
* @return string
193+
*/
194+
public function getDeprecated()
195+
{
196+
return $this->deprecated;
197+
}
198+
179199
/**
180200
* Getter for data's data type
181201
*

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public function __construct($entityObject, $dependentObjects = [], $customFields
5959
array_merge($entityObject->getAllData(), $customFields),
6060
$entityObject->getLinkedEntities(),
6161
$this->stripCustomFieldsFromUniquenessData($entityObject->getUniquenessData(), $customFields),
62-
$entityObject->getVarReferences()
62+
$entityObject->getVarReferences(),
63+
$entityObject->getParentName(),
64+
$entityObject->getFilename(),
65+
$entityObject->getDeprecated()
6366
);
6467
} else {
6568
$this->entityObject = clone $entityObject;

src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public function extendEntity($entityObject)
9393
$newUniqueReferences,
9494
$newVarReferences,
9595
$entityObject->getParentName(),
96-
$entityObject->getFilename()
96+
$entityObject->getFilename(),
97+
$entityObject->getDeprecated()
9798
);
9899
return $extendedEntity;
99100
}

src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
</xs:choice>
2323
<xs:attribute type="xs:string" name="name"/>
2424
<xs:attribute type="xs:string" name="dataType" use="required"/>
25+
<xs:attribute type="xs:string" name="deprecated">
26+
<xs:annotation>
27+
<xs:documentation>
28+
Message and flag which shows that entity is deprecated.
29+
</xs:documentation>
30+
</xs:annotation>
31+
</xs:attribute>
2532
<xs:attribute type="operationEnum" name="type" use="required"/>
2633
<xs:attribute type="xs:string" name="url"/>
2734
<xs:attribute type="authEnum" name="auth"/>

src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
</xs:documentation>
7070
</xs:annotation>
7171
</xs:attribute>
72+
<xs:attribute type="xs:string" name="deprecated">
73+
<xs:annotation>
74+
<xs:documentation>
75+
Message and flag which shows that entity is deprecated.
76+
</xs:documentation>
77+
</xs:annotation>
78+
</xs:attribute>
79+
7280
<xs:attribute type="xs:string" name="type">
7381
<xs:annotation>
7482
<xs:documentation>

src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface;
1010
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
1111
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
12+
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1213
use Magento\FunctionalTestingFramework\XmlParser\PageParser;
1314
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1415

@@ -68,9 +69,17 @@ private function __construct()
6869
$sectionNames = array_keys($pageData[self::SECTION] ?? []);
6970
$parameterized = $pageData[self::PARAMETERIZED] ?? false;
7071
$filename = $pageData[self::FILENAME] ?? null;
72+
$deprecated = $pageData['deprecated'] ?? null;
73+
74+
if ($deprecated !== null) {
75+
LoggingUtil::getInstance()->getLogger(self::class)->deprecation(
76+
$deprecated,
77+
["pageName" => $filename, "deprecatedPage" => $deprecated]
78+
);
79+
}
7180

7281
$this->pageObjects[$pageName] =
73-
new PageObject($pageName, $url, $module, $sectionNames, $parameterized, $area, $filename);
82+
new PageObject($pageName, $url, $module, $sectionNames, $parameterized, $area, $filename, $deprecated);
7483
}
7584
}
7685

0 commit comments

Comments
 (0)