diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/DataObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/DataObjectHandlerTest.php
index 9f1ca7b5c..745789501 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/DataObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/DataObjectHandlerTest.php
@@ -13,6 +13,7 @@
use Magento\FunctionalTestingFramework\ObjectManager;
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
/**
@@ -148,7 +149,7 @@ public function setUp(): void
*/
public function testGetAllObjects()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);
// Call the method under test
$actual = DataObjectHandler::getInstance()->getAllObjects();
@@ -164,7 +165,7 @@ public function testGetAllObjects()
*/
public function testDeprecatedDataObject()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT_DEPRECATED);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_DEPRECATED);
// Call the method under test
$actual = DataObjectHandler::getInstance()->getAllObjects();
@@ -182,7 +183,7 @@ public function testDeprecatedDataObject()
*/
public function testGetObject()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);
// Call the method under test
$actual = DataObjectHandler::getInstance()->getObject('EntityOne');
@@ -197,7 +198,7 @@ public function testGetObject()
*/
public function testGetObjectNull()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);
$actual = DataObjectHandler::getInstance()->getObject('h953u789h0g73t521'); // doesnt exist
$this->assertNull($actual);
@@ -208,7 +209,7 @@ public function testGetObjectNull()
*/
public function testGetAllObjectsWithDataExtends()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT_WITH_EXTEND);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND);
// Call the method under test
$actual = DataObjectHandler::getInstance()->getAllObjects();
@@ -232,7 +233,7 @@ public function testGetAllObjectsWithDataExtends()
*/
public function testGetObjectWithDataExtends()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT_WITH_EXTEND);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND);
// Call the method under test
$actual = DataObjectHandler::getInstance()->getObject('EntityTwo');
@@ -255,7 +256,7 @@ public function testGetObjectWithDataExtends()
*/
public function testGetAllObjectsWithDataExtendsItself()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);
$this->expectException(\Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException::class);
$this->expectExceptionMessage(
@@ -272,7 +273,7 @@ public function testGetAllObjectsWithDataExtendsItself()
*/
public function testGetObjectWithDataExtendsItself()
{
- $this->setUpMockDataObjectHander(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);
$this->expectException(\Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException::class);
$this->expectExceptionMessage(
@@ -286,33 +287,6 @@ public function testGetObjectWithDataExtendsItself()
);
}
- /**
- * Set up everything required to mock DataObjectHander::getInstance()
- * The first call to getInstance() uses these mocks to emulate the parser, initializing internal state
- * according to the PARSER_OUTPUT value
- *
- * @param array $entityDataArray
- */
- private function setUpMockDataObjectHander($entityDataArray)
- {
- // Clear DataObjectHandler singleton if already set
- $property = new \ReflectionProperty(DataObjectHandler::class, "INSTANCE");
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [
- 'readDataProfiles' => $entityDataArray
- ])->make();
-
- $mockObjectManager = AspectMock::double(ObjectManager::class, [
- 'create' => $mockDataProfileSchemaParser
- ])->make();
-
- AspectMock::double(ObjectManagerFactory::class, [
- 'getObjectManager' => $mockObjectManager
- ]);
- }
-
/**
* clean up function runs after all tests
*/
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/OperationDefinitionObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/OperationDefinitionObjectHandlerTest.php
index 570e8d95a..35b06a24a 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/OperationDefinitionObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/OperationDefinitionObjectHandlerTest.php
@@ -14,6 +14,7 @@
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\OperationDefinitionObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Parsers\OperationDefinitionParser;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
/**
@@ -72,7 +73,7 @@ public function testGetMultipleObjects()
],
]
]]];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
//Perform Assertions
$operationDefinitionManager = OperationDefinitionObjectHandler::getInstance();
@@ -109,7 +110,7 @@ public function testDeprecatedOperation()
],
OperationDefinitionObjectHandler::OBJ_DEPRECATED => 'deprecation message'
]]];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
//Perform Assertions
$operationDefinitionManager = OperationDefinitionObjectHandler::getInstance();
@@ -239,7 +240,7 @@ public function testObjectCreation()
);
// Set up mocked data output
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
// Get Operation
$operationDefinitionManager = OperationDefinitionObjectHandler::getInstance();
@@ -337,7 +338,7 @@ public function testObjectArrayCreation()
);
// Set up mocked data output
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
// Get Operation
$operationDefinitionManager = OperationDefinitionObjectHandler::getInstance();
@@ -405,7 +406,7 @@ public function testLooseJsonCreation()
);
// Set up mocked data output
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
// get Operations
$operationDefinitionManager = OperationDefinitionObjectHandler::getInstance();
@@ -416,29 +417,6 @@ public function testLooseJsonCreation()
$this->assertEquals($array, $operation->getOperationMetadata()[1]);
}
- /**
- * Function used to set mock for parser return and force init method to run between tests.
- *
- * @param array $data
- */
- private function setMockParserOutput($data)
- {
- // clear Operation object handler value to inject parsed content
- $property = new \ReflectionProperty(
- OperationDefinitionObjectHandler::class,
- 'INSTANCE'
- );
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockOperationParser = AspectMock::double(
- OperationDefinitionParser::class,
- ["readOperationMetadata" => $data]
- )->make();
- $instance = AspectMock::double(ObjectManager::class, ['create' => $mockOperationParser])->make();
- AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
- }
-
/**
* clean up function runs after all tests
*/
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php
index 870e75dcd..7e39fe216 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php
@@ -16,6 +16,7 @@
use Magento\FunctionalTestingFramework\ObjectManager;
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
/**
@@ -84,7 +85,7 @@ public function testCreateSimpleEntity()
";
// Mock Classes
- $this->mockDataHandlerWithOutput($parserOutput);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutput);
$this->mockCurlHandler($jsonResponse);
$handler = PersistedObjectHandler::getInstance();
@@ -127,7 +128,7 @@ public function testDeleteSimpleEntity()
";
// Mock Classes
- $this->mockDataHandlerWithOutput($parserOutput);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutput);
$this->mockCurlHandler($jsonResponse);
$handler = PersistedObjectHandler::getInstance();
@@ -175,7 +176,7 @@ public function testGetSimpleEntity()
";
// Mock Classes
- $this->mockDataHandlerWithOutput($parserOutput);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutput);
$this->mockCurlHandler($jsonResponse);
$handler = PersistedObjectHandler::getInstance();
@@ -235,7 +236,7 @@ public function testUpdateSimpleEntity()
";
// Mock Classes
- $this->mockDataHandlerWithOutput($parserOutput);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutput);
$this->mockCurlHandler($jsonResponse);
$handler = PersistedObjectHandler::getInstance();
$handler->createEntity(
@@ -322,7 +323,7 @@ public function testRetrieveEntityAcrossScopes()
// Mock Classes and Create Entities
$handler = PersistedObjectHandler::getInstance();
- $this->mockDataHandlerWithOutput($parserOutputOne);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutputOne);
$this->mockCurlHandler($jsonReponseOne);
$handler->createEntity(
$entityStepKeyOne,
@@ -399,7 +400,7 @@ public function testRetrieveEntityValidField($name, $key, $value, $type, $scope,
// Mock Classes and Create Entities
$handler = PersistedObjectHandler::getInstance();
- $this->mockDataHandlerWithOutput($parserOutputOne);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutputOne);
$this->mockCurlHandler($jsonReponseOne);
$handler->createEntity($stepKey, $scope, $name);
@@ -447,8 +448,7 @@ public function testRetrieveEntityInValidField($name, $key, $value, $type, $scop
// Mock Classes and Create Entities
$handler = PersistedObjectHandler::getInstance();
-
- $this->mockDataHandlerWithOutput($parserOutputOne);
+ ObjectHandlerUtil::mockDataObjectHandlerWithData($parserOutputOne);
$this->mockCurlHandler($jsonReponseOne);
$handler->createEntity($stepKey, $scope, $name);
@@ -475,31 +475,6 @@ public static function entityDataProvider()
];
}
- /**
- * Mocks DataObjectHandler to use given output to create
- * @param $parserOutput
- * @throws \Exception
- */
- public function mockDataHandlerWithOutput($parserOutput)
- {
- // Clear DataObjectHandler singleton if already set
- $property = new \ReflectionProperty(DataObjectHandler::class, "INSTANCE");
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [
- 'readDataProfiles' => $parserOutput
- ])->make();
-
- $mockObjectManager = AspectMock::double(ObjectManager::class, [
- 'create' => $mockDataProfileSchemaParser
- ])->make();
-
- AspectMock::double(ObjectManagerFactory::class, [
- 'getObjectManager' => $mockObjectManager
- ]);
- }
-
public function mockCurlHandler($response)
{
AspectMock::double(CurlHandler::class, [
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/PageObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/PageObjectHandlerTest.php
index c934b680b..eb305bc4d 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/PageObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/PageObjectHandlerTest.php
@@ -12,6 +12,7 @@
use Magento\FunctionalTestingFramework\Page\Handlers\PageObjectHandler;
use Magento\FunctionalTestingFramework\XmlParser\PageParser;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
class PageObjectHandlerTest extends MagentoTestCase
@@ -45,7 +46,7 @@ public function testGetPageObject()
],
"area" => "test"
]];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockPageObjectHandlerWithData($mockData);
// get pages
$pageHandler = PageObjectHandler::getInstance();
@@ -70,7 +71,7 @@ public function testGetEmptyPage()
],
"area" => "test"
]];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockPageObjectHandlerWithData($mockData);
// get pages
$page = PageObjectHandler::getInstance()->getObject('testPage1');
@@ -91,7 +92,7 @@ public function testDeprecatedPage()
"deprecated" => "deprecation message",
"filename" => "filename.xml"
]];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockPageObjectHandlerWithData($mockData);
// get pages
$page = PageObjectHandler::getInstance()->getObject('testPage1');
@@ -103,23 +104,6 @@ public function testDeprecatedPage()
);
}
- /**
- * Function used to set mock for parser return and force init method to run between tests.
- *
- * @param array $data
- */
- private function setMockParserOutput($data)
- {
- // clear section object handler value to inject parsed content
- $property = new \ReflectionProperty(PageObjectHandler::class, 'INSTANCE');
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockSectionParser = AspectMock::double(PageParser::class, ["getData" => $data])->make();
- $instance = AspectMock::double(ObjectManager::class, ['get' => $mockSectionParser])->make();
- AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
- }
-
/**
* clean up function runs after all tests
*/
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/SectionObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/SectionObjectHandlerTest.php
index 39e26caf9..69088944a 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/SectionObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/SectionObjectHandlerTest.php
@@ -12,6 +12,7 @@
use Magento\FunctionalTestingFramework\Page\Handlers\SectionObjectHandler;
use Magento\FunctionalTestingFramework\XmlParser\SectionParser;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
class SectionObjectHandlerTest extends MagentoTestCase
@@ -46,7 +47,7 @@ public function testGetSectionObject()
]
];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockSectionObjectHandlerWithData($mockData);
// get sections
$sectionHandler = SectionObjectHandler::getInstance();
@@ -77,7 +78,7 @@ public function testDeprecatedSection()
]
];
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockSectionObjectHandlerWithData($mockData);
// get sections
$sectionHandler = SectionObjectHandler::getInstance();
@@ -91,23 +92,6 @@ public function testDeprecatedSection()
);
}
- /**
- * Set the mock parser return value
- *
- * @param array $data
- */
- private function setMockParserOutput($data)
- {
- // clear section object handler value to inject parsed content
- $property = new \ReflectionProperty(SectionObjectHandler::class, "INSTANCE");
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockSectionParser = AspectMock::double(SectionParser::class, ["getData" => $data])->make();
- $instance = AspectMock::double(ObjectManager::class, ["get" => $mockSectionParser])->make();
- AspectMock::double(ObjectManagerFactory::class, ["getObjectManager" => $instance]);
- }
-
/**
* clean up function runs after all tests
*/
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/StaticCheck/DeprecatedEntityUsageCheckTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/StaticCheck/DeprecatedEntityUsageCheckTest.php
new file mode 100644
index 000000000..dc339c8a3
--- /dev/null
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/StaticCheck/DeprecatedEntityUsageCheckTest.php
@@ -0,0 +1,251 @@
+staticCheck = new DeprecatedEntityUsageCheck();
+ $this->staticCheckClass = new \ReflectionClass($this->staticCheck);
+ }
+
+ public function tearDown(): void
+ {
+ AspectMock::clean();
+ }
+
+ public function testInvalidPathOption()
+ {
+ $input = $this->getMockBuilder(InputInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $input->method('getOption')
+ ->with('path')
+ ->willReturn('/invalidPath');
+
+ $loadAllXmlFiles = $this->staticCheckClass->getMethod('loadAllXMLFiles');
+ $loadAllXmlFiles->setAccessible(true);
+
+ $this->expectException(InvalidArgumentException::class);
+ $loadAllXmlFiles->invoke($this->staticCheck, $input);
+ }
+
+ public function testViolatingElementReferences()
+ {
+ //variables for assertions
+ $elementName = 'elementOne';
+ $sectionName = 'SectionOne';
+ $fileName = 'section.xml';
+
+ $element = new ElementObject($elementName, 'type', '#selector1', null, '41', false, 'deprecated');
+ $section = new SectionObject($sectionName, [$element], $fileName);
+ $elementRef = $sectionName . '.' . $elementName;
+ $references = [$elementRef => $element, $sectionName => $section];
+ $actual = $this->callViolatingReferences($references);
+ $expected = [
+ 'Deprecated Element(s)' => [
+ 0 => [
+ 'name' => $elementRef,
+ 'file' => $fileName
+ ]
+ ]
+ ];
+ $this->assertEquals($actual, $expected);
+ }
+
+ public function testViolatingPageReferences()
+ {
+ //Page variables for assertions
+ $pageName = 'Page';
+ $fileName = 'page.xml';
+
+ $page = new PageObject($pageName, '/url.html', 'Test', [], false, "test", $fileName, 'deprecated');
+ $references = ['Page' => $page];
+ $actual = $this->callViolatingReferences($references);
+ $expected = [
+ 'Deprecated Page(s)' => [
+ 0 => [
+ 'name' => $pageName,
+ 'file' => $fileName
+ ]
+ ]
+ ];
+ $this->assertEquals($actual, $expected);
+ }
+
+ public function testViolatingDataReferences()
+ {
+ //Data entity variables for assertions
+ $entityName = 'EntityOne';
+ $fileName = 'entity.xml';
+
+ $entity = new EntityDataObject(
+ $entityName,
+ 'testType',
+ ['testkey' => 'testValue'],
+ [],
+ null,
+ [],
+ null,
+ $fileName,
+ 'deprecated'
+ );
+ $references = [$entityName => $entity];
+ $actual = $this->callViolatingReferences($references);
+ $expected = [
+ 'Deprecated Data(s)' => [
+ 0 => [
+ 'name' => $entityName,
+ 'file' => $fileName
+ ]
+ ]
+ ];
+ $this->assertEquals($actual, $expected);
+ }
+
+ public function testViolatingTestReferences()
+ {
+ // test variables for assertions
+ $testName = 'Test1';
+ $fileName = 'test.xml';
+
+ $test = new TestObject($testName, [], [], [], $fileName, null, 'deprecated');
+ $references = ['Test1' => $test];
+ $actual = $this->callViolatingReferences($references);
+ $expected = [
+ 'Deprecated Test(s)' => [
+ 0 => [
+ 'name' => $testName,
+ 'file' => $fileName
+ ]
+ ]
+ ];
+ $this->assertEquals($actual, $expected);
+ }
+
+ public function testViolatingMetaDataReferences()
+ {
+ // Data Variables for Assertions
+ $dataType1 = "type1";
+ $operationType1 = "create";
+ $operationType2 = "update";
+
+ /**
+ * Parser Output.
+ * operationName
+ * createType1
+ * has field
+ * key=id, value=integer
+ * updateType1
+ * has field
+ * key=id, value=integer
+ */
+ $mockData = [OperationDefinitionObjectHandler::ENTITY_OPERATION_ROOT_TAG => [
+ "testOperationName" => [
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_DATA_TYPE => $dataType1,
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_TYPE => $operationType1,
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_AUTH => "auth",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_URL => "V1/Type1",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_METHOD => "POST",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY => [
+ 0 => [
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY_KEY => "id",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY_VALUE => "integer"
+ ],
+ ],
+ OperationDefinitionObjectHandler::OBJ_DEPRECATED => 'deprecated'
+ ],[
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_DATA_TYPE => $dataType1,
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_TYPE => $operationType2,
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_AUTH => "auth",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_URL => "V1/Type1/{id}",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_METHOD => "PUT",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY => [
+ 0 => [
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY_KEY => "id",
+ OperationDefinitionObjectHandler::ENTITY_OPERATION_ENTRY_VALUE => "integer"
+ ],
+ ]
+ ]]];
+
+ ObjectHandlerUtil::mockOperationHandlerWithData($mockData);
+ $dataName = 'dataName1';
+ $references = [
+ $dataName => [
+ $dataType1 => [
+ $operationType1,
+ $operationType2
+ ]
+ ]
+ ];
+
+ $expected = [
+ '"'.$dataName.'" references deprecated' => [
+ 0 => [
+ 'name' => $dataType1,
+ 'file' => 'metadata xml file'
+ ]
+ ]
+ ];
+ $property = $this->staticCheckClass->getMethod('findViolatingMetadataReferences');
+ $property->setAccessible(true);
+ $actual = $property->invoke($this->staticCheck, $references);
+ $this->assertEquals($actual, $expected);
+ }
+
+ public function testIsDeprecated()
+ {
+ // Test Data
+ $contents = '
+
+
+
+
+
+ ';
+
+ $property = $this->staticCheckClass->getMethod('isDeprecated');
+ $property->setAccessible(true);
+ $output = $property->invoke($this->staticCheck, $contents);
+ $this->assertTrue($output);
+ }
+
+ /**
+ * Invoke findViolatingReferences
+ * @param $references
+ * @return mixed
+ * @throws \ReflectionException
+ */
+ public function callViolatingReferences($references)
+ {
+ $property = $this->staticCheckClass->getMethod('findViolatingReferences');
+ $property->setAccessible(true);
+ return $property->invoke($this->staticCheck, $references);
+ }
+}
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/ActionGroupObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/ActionGroupObjectHandlerTest.php
index deb08d783..71c1833ba 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/ActionGroupObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/ActionGroupObjectHandlerTest.php
@@ -15,6 +15,7 @@
use tests\unit\Util\MagentoTestCase;
use tests\unit\Util\ActionGroupArrayBuilder;
use Magento\FunctionalTestingFramework\Test\Parsers\ActionGroupDataParser;
+use tests\unit\Util\ObjectHandlerUtil;
class ActionGroupObjectHandlerTest extends MagentoTestCase
{
@@ -34,7 +35,7 @@ public function testGetTestObjectWithInvalidExtends()
->withFilename()
->withActionObjects()
->build();
- $this->setMockParserOutput(['actionGroups' => $actionGroupOne]);
+ ObjectHandlerUtil::mockActionGroupObjectHandlerWithData(['actionGroups' => $actionGroupOne]);
$handler = ActionGroupObjectHandler::getInstance();
@@ -68,7 +69,14 @@ public function testGetAllTestObjectsWithInvalidExtends()
->withActionObjects()
->build();
- $this->setMockParserOutput(['actionGroups' => array_merge($actionGroupOne, $actionGroupTwo)]);
+ ObjectHandlerUtil::mockActionGroupObjectHandlerWithData(
+ [
+ 'actionGroups' => array_merge(
+ $actionGroupOne,
+ $actionGroupTwo
+ )
+ ]
+ );
$handler = ActionGroupObjectHandler::getInstance();
@@ -76,23 +84,4 @@ public function testGetAllTestObjectsWithInvalidExtends()
$this->expectExceptionMessage("Mftf Action Group can not extend from itself: " . $nameOne);
$handler->getAllObjects();
}
-
- /**
- * Function used to set mock for parser return and force init method to run between tests.
- *
- * @param array $data
- * @throws \Exception
- */
- private function setMockParserOutput($data)
- {
- // Clear action group object handler value to inject parsed content
- $property = new \ReflectionProperty(ActionGroupObjectHandler::class, 'instance');
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockDataParser = AspectMock::double(ActionGroupDataParser::class, ['readActionGroupData' => $data])->make();
- $instance = AspectMock::double(ObjectManager::class, ['create' => $mockDataParser])
- ->make(); // bypass the private constructor
- AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
- }
}
diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php
index 4db2f21a4..897ba0ea9 100644
--- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php
+++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php
@@ -17,6 +17,7 @@
use Magento\FunctionalTestingFramework\Test\Parsers\TestDataParser;
use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor;
use tests\unit\Util\MagentoTestCase;
+use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestDataArrayBuilder;
use tests\unit\Util\MockModuleResolverBuilder;
@@ -41,7 +42,7 @@ public function testGetTestObject()
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockTestObjectHandlerWitData($mockData);
// run object handler method
$toh = TestObjectHandler::getInstance();
@@ -135,7 +136,7 @@ public function testGetTestsByGroup()
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
- $this->setMockParserOutput(array_merge($includeTest, $excludeTest));
+ ObjectHandlerUtil::mockTestObjectHandlerWitData(array_merge($includeTest, $excludeTest));
// execute test method
$toh = TestObjectHandler::getInstance();
@@ -184,7 +185,7 @@ public function testGetTestWithModuleName()
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup(['Vendor_' . $moduleExpected => $filepath]);
- $this->setMockParserOutput($mockData);
+ ObjectHandlerUtil::mockTestObjectHandlerWitData($mockData);
// Execute Test Method
$toh = TestObjectHandler::getInstance();
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);
@@ -212,7 +213,7 @@ public function testGetTestObjectWithInvalidExtends()
->build();
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
- $this->setMockParserOutput($testOne);
+ ObjectHandlerUtil::mockTestObjectHandlerWitData($testOne);
$toh = TestObjectHandler::getInstance();
@@ -250,7 +251,7 @@ public function testGetAllTestObjectsWithInvalidExtends()
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
- $this->setMockParserOutput(array_merge($testOne, $testTwo));
+ ObjectHandlerUtil::mockTestObjectHandlerWitData(array_merge($testOne, $testTwo));
$toh = TestObjectHandler::getInstance();
@@ -259,25 +260,6 @@ public function testGetAllTestObjectsWithInvalidExtends()
$toh->getAllObjects();
}
- /**
- * Function used to set mock for parser return and force init method to run between tests.
- *
- * @param array $data
- * @throws \Exception
- */
- private function setMockParserOutput($data)
- {
- // clear test object handler value to inject parsed content
- $property = new \ReflectionProperty(TestObjectHandler::class, 'testObjectHandler');
- $property->setAccessible(true);
- $property->setValue(null);
-
- $mockDataParser = AspectMock::double(TestDataParser::class, ['readTestData' => $data])->make();
- $instance = AspectMock::double(ObjectManager::class, ['create' => $mockDataParser])
- ->make(); // bypass the private constructor
- AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
- }
-
/**
* After method functionality
*
diff --git a/dev/tests/unit/Util/ObjectHandlerUtil.php b/dev/tests/unit/Util/ObjectHandlerUtil.php
new file mode 100644
index 000000000..0e4543f2b
--- /dev/null
+++ b/dev/tests/unit/Util/ObjectHandlerUtil.php
@@ -0,0 +1,145 @@
+setAccessible(true);
+ $property->setValue(null);
+
+ $mockOperationParser = AspectMock::double(
+ OperationDefinitionParser::class,
+ ["readOperationMetadata" => $data]
+ )->make();
+ $instance = AspectMock::double(ObjectManager::class, ['create' => $mockOperationParser])->make();
+ AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
+ }
+
+ /**
+ * Set up everything required to mock DataObjectHandler::getInstance() with $data value
+ *
+ * @param array $data
+ */
+ public static function mockDataObjectHandlerWithData($data)
+ {
+ // Clear DataObjectHandler singleton if already set
+ $property = new \ReflectionProperty(DataObjectHandler::class, "INSTANCE");
+ $property->setAccessible(true);
+ $property->setValue(null);
+
+ $mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [
+ 'readDataProfiles' => $data
+ ])->make();
+
+ $mockObjectManager = AspectMock::double(ObjectManager::class, [
+ 'create' => $mockDataProfileSchemaParser
+ ])->make();
+
+ AspectMock::double(ObjectManagerFactory::class, [
+ 'getObjectManager' => $mockObjectManager
+ ]);
+ }
+
+ /**
+ * Set up everything required to mock PageObjectHandler::getInstance() with $data value
+ *
+ * @param array $data
+ */
+ public static function mockPageObjectHandlerWithData($data)
+ {
+ // clear section object handler value to inject parsed content
+ $property = new \ReflectionProperty(PageObjectHandler::class, 'INSTANCE');
+ $property->setAccessible(true);
+ $property->setValue(null);
+
+ $mockSectionParser = AspectMock::double(PageParser::class, ["getData" => $data])->make();
+ $instance = AspectMock::double(ObjectManager::class, ['get' => $mockSectionParser])->make();
+ AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
+ }
+
+ /**
+ * Set up everything required to mock SectionObjectHandler::getInstance() with $data value
+ *
+ * @param array $data
+ */
+ public static function mockSectionObjectHandlerWithData($data)
+ {
+ // clear section object handler value to inject parsed content
+ $property = new \ReflectionProperty(SectionObjectHandler::class, "INSTANCE");
+ $property->setAccessible(true);
+ $property->setValue(null);
+
+ $mockSectionParser = AspectMock::double(SectionParser::class, ["getData" => $data])->make();
+ $instance = AspectMock::double(ObjectManager::class, ["get" => $mockSectionParser])->make();
+ AspectMock::double(ObjectManagerFactory::class, ["getObjectManager" => $instance]);
+ }
+
+ /**
+ * Set up everything required to mock TestObjectHandler::getInstance() with $data value
+ *
+ * @param array $data
+ * @throws \Exception
+ */
+ public static function mockTestObjectHandlerWitData($data)
+ {
+ // clear test object handler value to inject parsed content
+ $property = new \ReflectionProperty(TestObjectHandler::class, 'testObjectHandler');
+ $property->setAccessible(true);
+ $property->setValue(null);
+
+ $mockDataParser = AspectMock::double(TestDataParser::class, ['readTestData' => $data])->make();
+ $instance = AspectMock::double(ObjectManager::class, ['create' => $mockDataParser])
+ ->make(); // bypass the private constructor
+ AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
+ }
+
+ /**
+ * Set up everything required to mock ActionGroupObjectHandler::getInstance() with $data value
+ *
+ * @param array $data
+ * @throws \Exception
+ */
+ public static function mockActionGroupObjectHandlerWithData($data)
+ {
+ // Clear action group object handler value to inject parsed content
+ $property = new \ReflectionProperty(ActionGroupObjectHandler::class, 'instance');
+ $property->setAccessible(true);
+ $property->setValue(null);
+
+ $mockDataParser = AspectMock::double(ActionGroupDataParser::class, ['readActionGroupData' => $data])->make();
+ $instance = AspectMock::double(ObjectManager::class, ['create' => $mockDataParser])
+ ->make(); // bypass the private constructor
+ AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
+ }
+}
diff --git a/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckActionGroup.xml b/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckActionGroup.xml
new file mode 100644
index 000000000..c83dab211
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckActionGroup.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckDeprecatedActionGroup.xml b/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckDeprecatedActionGroup.xml
new file mode 100644
index 000000000..e8412a29e
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckDeprecatedActionGroup.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Data/DeprecationCheckData.xml b/dev/tests/verification/DeprecationCheckModule/Data/DeprecationCheckData.xml
new file mode 100644
index 000000000..75a6b6678
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Data/DeprecationCheckData.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ value
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Metadata/DeprecationCheckMeta.xml b/dev/tests/verification/DeprecationCheckModule/Metadata/DeprecationCheckMeta.xml
new file mode 100644
index 000000000..757c6284b
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Metadata/DeprecationCheckMeta.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ application/json
+
+
+
\ No newline at end of file
diff --git a/dev/tests/verification/DeprecationCheckModule/Page/DeprecationCheckPage.xml b/dev/tests/verification/DeprecationCheckModule/Page/DeprecationCheckPage.xml
new file mode 100644
index 000000000..dd3f187dc
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Page/DeprecationCheckPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Section/DeprecationCheckSection.xml b/dev/tests/verification/DeprecationCheckModule/Section/DeprecationCheckSection.xml
new file mode 100644
index 000000000..1837e1ef5
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Section/DeprecationCheckSection.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Suite/deprecationCheckSuite.xml b/dev/tests/verification/DeprecationCheckModule/Suite/deprecationCheckSuite.xml
new file mode 100644
index 000000000..b89ad99f6
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Suite/deprecationCheckSuite.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckDeprecatedTest.xml b/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckDeprecatedTest.xml
new file mode 100644
index 000000000..1b3ace053
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckDeprecatedTest.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckTest.xml b/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckTest.xml
new file mode 100644
index 000000000..1c4fc3dba
--- /dev/null
+++ b/dev/tests/verification/DeprecationCheckModule/Test/DeprecationCheckTest.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/verification/Resources/StaticChecks/mftf-deprecated-entity-usage-checks.txt b/dev/tests/verification/Resources/StaticChecks/mftf-deprecated-entity-usage-checks.txt
new file mode 100644
index 000000000..63e025470
--- /dev/null
+++ b/dev/tests/verification/Resources/StaticChecks/mftf-deprecated-entity-usage-checks.txt
@@ -0,0 +1,23 @@
+
+File "/verification/DeprecationCheckModule/Test/DeprecationCheckTest.xml" contains:
+ - Deprecated Page(s):
+ "DeprecationCheckPage" in /verification/DeprecationCheckModule/Page/DeprecationCheckPage.xml
+ - Deprecated ActionGroup(s):
+ "DeprecationCheckDeprecatedActionGroup" in /verification/DeprecationCheckModule/ActionGroup/DeprecationCheckDeprecatedActionGroup.xml
+ - Deprecated Data(s):
+ "DeprecationCheckData" in /verification/DeprecationCheckModule/Data/DeprecationCheckData.xml
+ - "DeprecationCheckData" references deprecated:
+ "type1" in metadata xml file
+
+
+File "/verification/DeprecationCheckModule/ActionGroup/DeprecationCheckActionGroup.xml" contains:
+ - Deprecated Section(s):
+ "DeprecationCheckSection" in /verification/DeprecationCheckModule/Section/DeprecationCheckSection.xml
+ - Deprecated Element(s):
+ "DeprecationCheckSection.deprecationCheckElement" in /verification/DeprecationCheckModule/Section/DeprecationCheckSection.xml
+
+
+File "/verification/DeprecationCheckModule/Suite/deprecationCheckSuite.xml" contains:
+ - Deprecated Test(s):
+ "DeprecationCheckDeprecatedTest" in /verification/DeprecationCheckModule/Test/DeprecationCheckDeprecatedTest.xml
+
diff --git a/dev/tests/verification/Tests/StaticCheck/DeprecationStaticCheckTest.php b/dev/tests/verification/Tests/StaticCheck/DeprecationStaticCheckTest.php
new file mode 100644
index 000000000..bafe586ac
--- /dev/null
+++ b/dev/tests/verification/Tests/StaticCheck/DeprecationStaticCheckTest.php
@@ -0,0 +1,92 @@
+mockInputInterface(self::TEST_MODULE_PATH);
+ AspectMock::double(StaticChecksList::class, ['getErrorFilesPath' => self::STATIC_RESULTS_DIR]);
+
+ /** @var InputInterface $input */
+ $staticCheck->execute($input);
+
+ $this->assertTrue(file_exists(self::LOG_FILE));
+ $this->assertFileEquals(
+ self::RESOURCES_PATH.
+ DIRECTORY_SEPARATOR .
+ DeprecatedEntityUsageCheck::ERROR_LOG_FILENAME .
+ ".txt",
+ self::LOG_FILE
+ );
+ }
+
+ /**
+ * Sets input interface
+ * @param $path
+ * @return \PHPUnit\Framework\MockObject\MockObject
+ */
+ public function mockInputInterface($path)
+ {
+ $input = $this->getMockBuilder(InputInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $input->method('getOption')
+ ->with('path')
+ ->willReturn($path);
+ return $input;
+ }
+
+ public function tearDown(): void
+ {
+ DirSetupUtil::rmdirRecursive(self::STATIC_RESULTS_DIR);
+ }
+}
diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/DeprecatedEntityUsageCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/DeprecatedEntityUsageCheck.php
index 5da16ec6a..547e6a633 100644
--- a/src/Magento/FunctionalTestingFramework/StaticCheck/DeprecatedEntityUsageCheck.php
+++ b/src/Magento/FunctionalTestingFramework/StaticCheck/DeprecatedEntityUsageCheck.php
@@ -37,6 +37,7 @@ class DeprecatedEntityUsageCheck implements StaticCheckInterface
{
const EXTENDS_REGEX_PATTERN = '/extends=["\']([^\'"]*)/';
const ACTIONGROUP_REGEX_PATTERN = '/ref=["\']([^\'"]*)/';
+ const DEPRECATED_REGEX_PATTERN = '/deprecated=["\']([^\'"]*)/';
const ERROR_LOG_FILENAME = 'mftf-deprecated-entity-usage-checks';
const ERROR_LOG_MESSAGE = 'MFTF Deprecated Entity Usage Check';
@@ -177,7 +178,6 @@ private function loadAllXmlFiles($input)
MftfApplicationConfig::LEVEL_DEFAULT,
true
);
- putenv('CUSTOM_MODULE_PATHS=' . realpath($path));
$modulePaths[] = realpath($path);
$includeRootPath = false;
} else {
@@ -225,6 +225,9 @@ private function findReferenceErrorsInActionFiles($files, $checkTestRef = false)
/** @var SplFileInfo $filePath */
foreach ($files as $filePath) {
$contents = file_get_contents($filePath);
+ if ($this->isDeprecated($contents)) {
+ continue;
+ }
preg_match_all(ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN, $contents, $braceReferences);
preg_match_all(self::ACTIONGROUP_REGEX_PATTERN, $contents, $actionGroupReferences);
preg_match_all(self::EXTENDS_REGEX_PATTERN, $contents, $extendReferences);
@@ -316,6 +319,17 @@ private function findReferenceErrorsInActionFiles($files, $checkTestRef = false)
return $testErrors;
}
+ /**
+ * Checks if entity is deprecated in action files.
+ * @param string $contents
+ * @return boolean
+ */
+ private function isDeprecated($contents)
+ {
+ preg_match_all(self::DEPRECATED_REGEX_PATTERN, $contents, $deprecatedEntity);
+ return (!empty($deprecatedEntity[1]));
+ }
+
/**
* Find reference errors in a set of data files
*
@@ -335,6 +349,11 @@ private function findReferenceErrorsInDataFiles($files)
$entities = $domDocument->getElementsByTagName('entity');
foreach ($entities as $entity) {
/** @var DOMElement $entity */
+ $deprecated = $entity->getAttribute('deprecated');
+ // skip check if entity is deprecated
+ if (!empty($deprecated)) {
+ continue;
+ }
$entityName = $entity->getAttribute('name');
$metadataType = $entity->getAttribute('type');
$parentEntityName = $entity->getAttribute('extends');
@@ -609,9 +628,9 @@ private function findViolatingReferences($references)
$name = $key;
list($section,) = explode('.', $key, 2);
/** @var SectionObject $references[$section] */
- $file = $references[$section]->getFilename();
+ $file = StaticChecksList::getFilePath($references[$section]->getFilename());
} else {
- $file = $entity->getFilename();
+ $file = StaticChecksList::getFilePath($entity->getFilename());
}
$violatingReferences[$this->getSubjectFromClassType($classType)][] = [
'name' => $name,
@@ -633,16 +652,18 @@ private function setErrorOutput($violatingReferences, $path)
{
$testErrors = [];
+ $filePath = StaticChecksList::getFilePath($path->getRealPath());
+
if (!empty($violatingReferences)) {
// Build error output
- $errorOutput = "\nFile \"{$path->getRealPath()}\" contains:\n";
+ $errorOutput = "\nFile \"{$filePath}\" contains:\n";
foreach ($violatingReferences as $subject => $data) {
$errorOutput .= "\t- {$subject}:\n";
foreach ($data as $item) {
$errorOutput .= "\t\t\"" . $item['name'] . "\" in " . $item['file'] . "\n";
}
}
- $testErrors[$path->getRealPath()][] = $errorOutput;
+ $testErrors[$filePath][] = $errorOutput;
}
return $testErrors;
diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php
index 7cd894e00..ba2139276 100644
--- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php
+++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php
@@ -69,4 +69,22 @@ public static function getErrorFilesPath()
{
return self::$errorFilesPath;
}
+
+ /**
+ * Return relative path to files for unit testing purposes.
+ * @param string $fileNames
+ * @return string
+ */
+ public static function getFilePath($fileNames)
+ {
+ if (!empty($fileNames)) {
+ $relativeFileNames = ltrim(
+ str_replace(MAGENTO_BP, '', $fileNames)
+ );
+ if (!empty($relativeFileNames)) {
+ return $relativeFileNames;
+ }
+ }
+ return $fileNames;
+ }
}