|
14 | 14 | use Magento\Framework\App\Utility\AggregateInvoker;
|
15 | 15 | use Magento\TestFramework\Utility\ChangedFiles;
|
16 | 16 |
|
| 17 | +/** |
| 18 | + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
| 19 | + */ |
17 | 20 | class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
|
18 | 21 | {
|
19 | 22 | /**@#+
|
@@ -871,7 +874,7 @@ protected function _assertNotRegexp($regex, $content, $message)
|
871 | 874 |
|
872 | 875 | public function testMageMethodsObsolete()
|
873 | 876 | {
|
874 |
| - $ignored = $this->getBlacklistFiles(); |
| 877 | + $ignored = $this->getBlacklistFiles(true); |
875 | 878 | $files = Files::init()->getPhpFiles(
|
876 | 879 | Files::INCLUDE_APP_CODE
|
877 | 880 | | Files::INCLUDE_TESTS
|
@@ -900,18 +903,43 @@ function ($file) {
|
900 | 903 | );
|
901 | 904 | }
|
902 | 905 |
|
| 906 | + /** |
| 907 | + * @param string $appPath |
| 908 | + * @param string $pattern |
| 909 | + * @return array |
| 910 | + * @throws \Exception |
| 911 | + */ |
| 912 | + private function processPattern($appPath, $pattern) |
| 913 | + { |
| 914 | + $files = []; |
| 915 | + $relativePathStart = strlen($appPath); |
| 916 | + |
| 917 | + $fileSet = glob($appPath . DIRECTORY_SEPARATOR . $pattern, GLOB_NOSORT); |
| 918 | + foreach ($fileSet as $file) { |
| 919 | + $files[] = substr($file, $relativePathStart); |
| 920 | + } |
| 921 | + |
| 922 | + return $files; |
| 923 | + } |
| 924 | + |
903 | 925 | /**
|
904 | 926 | * Reads list of blacklisted files
|
905 | 927 | *
|
| 928 | + * @param bool $absolutePath |
906 | 929 | * @return array
|
| 930 | + * @throws \Exception |
907 | 931 | */
|
908 |
| - private function getBlacklistFiles() |
| 932 | + private function getBlacklistFiles($absolutePath = false) |
909 | 933 | {
|
910 | 934 | $blackList = include __DIR__ . '/_files/blacklist/obsolete_mage.php';
|
911 | 935 | $ignored = [];
|
912 | 936 | $appPath = Files::init()->getPathToSource();
|
913 | 937 | foreach ($blackList as $file) {
|
914 |
| - $ignored = array_merge($ignored, glob($appPath . '/' . $file, GLOB_NOSORT)); |
| 938 | + if ($absolutePath) { |
| 939 | + $ignored = array_merge($ignored, glob($appPath . DIRECTORY_SEPARATOR . $file, GLOB_NOSORT)); |
| 940 | + } else { |
| 941 | + $ignored = array_merge($ignored, $this->processPattern($appPath, $file)); |
| 942 | + } |
915 | 943 | }
|
916 | 944 | return $ignored;
|
917 | 945 | }
|
|
0 commit comments