Skip to content

Commit ec118e5

Browse files
authored
Update TestDependencyUtil.php
1 parent 9d985ca commit ec118e5

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

src/Magento/FunctionalTestingFramework/Util/Script/TestDependencyUtil.php

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
namespace Magento\FunctionalTestingFramework\Util\Script;
77

8+
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
9+
use Magento\FunctionalTestingFramework\Filter\FilterList;
10+
11+
812
/**
913
* TestDependencyUtil class that contains helper functions for static and upgrade scripts
1014
*
@@ -153,6 +157,7 @@ public function mergeDependenciesForExtendingTests(
153157
array $filterList,
154158
array $extendedTestMapping = []
155159
): array {
160+
$filteredTestNames = (count($filterList)>0)?$this->getFilteredValues($filterList):[];
156161
$temp_array = array_reverse(array_column($testDependencies, "test_name"), true);
157162
if (!empty($extendedTestMapping)) {
158163
foreach ($extendedTestMapping as $value) {
@@ -169,18 +174,7 @@ public function mergeDependenciesForExtendingTests(
169174
}
170175
$testDependencies = [];
171176
foreach ($temp_array as $testDependencyArray) {
172-
$domDocument = new \DOMDocument();
173-
$domDocument->load($testDependencyArray[0]["file_path"]);
174-
$filterResult = $this->getAttributesFromDOMNodeList(
175-
$domDocument->getElementsByTagName("group"),
176-
["type" => "value"]
177-
);
178-
$excludeGroup = $filterList['excludeGroup']??[];
179-
if (count(array_intersect(
180-
call_user_func_array('array_merge', $filterResult),
181-
$excludeGroup
182-
))==0
183-
) {
177+
if((empty($filteredTestNames)) || (in_array($testDependencyArray[0]["test_name"],$filteredTestNames))) {
184178
$testDependencies[] = [
185179
"file_path" => array_column($testDependencyArray, 'file_path'),
186180
"full_name" => $testDependencyArray[0]["full_name"],
@@ -200,26 +194,18 @@ public function mergeDependenciesForExtendingTests(
200194
}
201195

202196
/**
203-
* Return attribute value for each node in DOMNodeList as an array
204-
*
205-
* @param DOMNodeList $nodes
206-
* @param string $attributeName
207197
* @return array
208198
*/
209-
private function getAttributesFromDOMNodeList($nodes, $attributeName)
210-
{
211-
$attributes = [];
212-
foreach ($nodes as $node) {
213-
if (is_string($attributeName)) {
214-
$attributeValues = $node->getAttribute($attributeName);
215-
} else {
216-
$attributeValues = [$node->getAttribute(key($attributeName)) =>
217-
$node->getAttribute($attributeName[key($attributeName)])];
218-
}
219-
if (!empty($attributeValues)) {
220-
$attributes[] = array_values($attributeValues);
221-
}
199+
public function getFilteredValues(array $filterList) {
200+
201+
$testObjects = TestObjectHandler::getInstance()->getAllObjects();
202+
$fileList = new FilterList($filterList);
203+
foreach( $fileList->getFilters() as $filterData) {
204+
$filterData->filter($testObjects);
205+
}
206+
foreach ($testObjects as $testObjects) {
207+
$testNames[] = $testObjects->getName();
222208
}
223-
return array_values($attributes);
209+
return $testNames;
224210
}
225211
}

0 commit comments

Comments
 (0)