Skip to content
Snippets Groups Projects
Commit e1d3ef02 authored by Ievgen Sentiabov's avatar Ievgen Sentiabov
Browse files

Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into MAGETWO-43948

parents 0ebfe364 2ed35e64
Branches
No related merge requests found
...@@ -14,6 +14,9 @@ use Magento\Framework\App\Utility\Files; ...@@ -14,6 +14,9 @@ use Magento\Framework\App\Utility\Files;
use Magento\Framework\App\Utility\AggregateInvoker; use Magento\Framework\App\Utility\AggregateInvoker;
use Magento\TestFramework\Utility\ChangedFiles; use Magento\TestFramework\Utility\ChangedFiles;
/**
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
{ {
/**@#+ /**@#+
...@@ -871,7 +874,7 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase ...@@ -871,7 +874,7 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
public function testMageMethodsObsolete() public function testMageMethodsObsolete()
{ {
$ignored = $this->getBlacklistFiles(); $ignored = $this->getBlacklistFiles(true);
$files = Files::init()->getPhpFiles( $files = Files::init()->getPhpFiles(
Files::INCLUDE_APP_CODE Files::INCLUDE_APP_CODE
| Files::INCLUDE_TESTS | Files::INCLUDE_TESTS
...@@ -900,18 +903,43 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase ...@@ -900,18 +903,43 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
); );
} }
/**
* @param string $appPath
* @param string $pattern
* @return array
* @throws \Exception
*/
private function processPattern($appPath, $pattern)
{
$files = [];
$relativePathStart = strlen($appPath);
$fileSet = glob($appPath . DIRECTORY_SEPARATOR . $pattern, GLOB_NOSORT);
foreach ($fileSet as $file) {
$files[] = substr($file, $relativePathStart);
}
return $files;
}
/** /**
* Reads list of blacklisted files * Reads list of blacklisted files
* *
* @param bool $absolutePath
* @return array * @return array
* @throws \Exception
*/ */
private function getBlacklistFiles() private function getBlacklistFiles($absolutePath = false)
{ {
$blackList = include __DIR__ . '/_files/blacklist/obsolete_mage.php'; $blackList = include __DIR__ . '/_files/blacklist/obsolete_mage.php';
$ignored = []; $ignored = [];
$appPath = Files::init()->getPathToSource(); $appPath = Files::init()->getPathToSource();
foreach ($blackList as $file) { foreach ($blackList as $file) {
$ignored = array_merge($ignored, glob($appPath . '/' . $file, GLOB_NOSORT)); if ($absolutePath) {
$ignored = array_merge($ignored, glob($appPath . DIRECTORY_SEPARATOR . $file, GLOB_NOSORT));
} else {
$ignored = array_merge($ignored, $this->processPattern($appPath, $file));
}
} }
return $ignored; return $ignored;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment