Skip to content

Commit dbf4c64

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-44167: ObsoleteCodeTest ignores blacklist
refactored code
1 parent 507c969 commit dbf4c64

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ protected function _assertNotRegexp($regex, $content, $message)
871871

872872
public function testMageMethodsObsolete()
873873
{
874-
$ignored = $this->getBlacklistFiles();
874+
$ignored = $this->getBlacklistFiles(true);
875875
$files = Files::init()->getPhpFiles(
876876
Files::INCLUDE_APP_CODE
877877
| Files::INCLUDE_TESTS
@@ -901,14 +901,14 @@ function ($file) {
901901
}
902902

903903
/**
904+
* @param string $appPath
904905
* @param string $pattern
905906
* @return array
906907
* @throws \Exception
907908
*/
908-
private function processPattern($pattern)
909+
private function processPattern($appPath, $pattern)
909910
{
910911
$files = [];
911-
$appPath = Files::init()->getPathToSource();
912912
$relativePathStart = strlen($appPath);
913913

914914
$fileSet = glob($appPath . DIRECTORY_SEPARATOR . $pattern, GLOB_NOSORT);
@@ -922,14 +922,21 @@ private function processPattern($pattern)
922922
/**
923923
* Reads list of blacklisted files
924924
*
925+
* @param bool $absolutePath
925926
* @return array
927+
* @throws \Exception
926928
*/
927-
private function getBlacklistFiles()
929+
private function getBlacklistFiles($absolutePath = false)
928930
{
929931
$blackList = include __DIR__ . '/_files/blacklist/obsolete_mage.php';
930932
$ignored = [];
933+
$appPath = Files::init()->getPathToSource();
931934
foreach ($blackList as $file) {
932-
$ignored = array_merge($ignored, $this->processPattern($file));
935+
if ($absolutePath) {
936+
$ignored = array_merge($ignored, glob($appPath . DIRECTORY_SEPARATOR . $file, GLOB_NOSORT));
937+
} else {
938+
$ignored = array_merge($ignored, $this->processPattern($appPath, $file));
939+
}
933940
}
934941
return $ignored;
935942
}

0 commit comments

Comments
 (0)