diff --git a/composer.lock b/composer.lock
index 5e5f24e81a01e..2c28e49a3e7b5 100644
--- a/composer.lock
+++ b/composer.lock
@@ -9368,16 +9368,16 @@
},
{
"name": "magento/magento-coding-standard",
- "version": "13",
+ "version": "14",
"source": {
"type": "git",
"url": "https://github.com/magento/magento-coding-standard.git",
- "reference": "2b58f92a98650e0d743aaf32c8c53e4127833eaa"
+ "reference": "daf56b857bec7add42108651365af3861dec290f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/magento/magento-coding-standard/zipball/2b58f92a98650e0d743aaf32c8c53e4127833eaa",
- "reference": "2b58f92a98650e0d743aaf32c8c53e4127833eaa",
+ "url": "https://api.github.com/repos/magento/magento-coding-standard/zipball/daf56b857bec7add42108651365af3861dec290f",
+ "reference": "daf56b857bec7add42108651365af3861dec290f",
"shasum": ""
},
"require": {
@@ -9396,7 +9396,8 @@
"PHP_CodeSniffer/Tokenizers/"
],
"psr-4": {
- "Magento2\\": "Magento2/"
+ "Magento2\\": "Magento2/",
+ "Magento2Framework\\": "Magento2Framework/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -9405,7 +9406,11 @@
"AFL-3.0"
],
"description": "A set of Magento specific PHP CodeSniffer rules.",
- "time": "2021-10-05T14:00:39+00:00"
+ "support": {
+ "issues": "https://github.com/magento/magento-coding-standard/issues",
+ "source": "https://github.com/magento/magento-coding-standard/tree/v14"
+ },
+ "time": "2021-11-02T12:16:53+00:00"
},
{
"name": "magento/magento2-functional-testing-framework",
diff --git a/dev/tests/static/framework/Magento/ruleset.xml b/dev/tests/static/framework/Magento/ruleset.xml
index 166965ed74492..cf25a7a04e01b 100644
--- a/dev/tests/static/framework/Magento/ruleset.xml
+++ b/dev/tests/static/framework/Magento/ruleset.xml
@@ -8,4 +8,7 @@
Custom Magento coding standard.
+
+ *\.min.js$
+ lib\/web\/(?!mage)
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/ClassesTest.php
deleted file mode 100644
index 0081c4081bbb8..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/ClassesTest.php
+++ /dev/null
@@ -1,128 +0,0 @@
-_assertNonFactoryName($classes, $file);
- },
- Files::init()->getPhpFiles(
- Files::INCLUDE_APP_CODE
- | Files::INCLUDE_PUB_CODE
- | Files::INCLUDE_LIBS
- | Files::INCLUDE_TEMPLATES
- | Files::AS_DATA_SET
- | Files::INCLUDE_NON_CLASSES
- )
- );
- }
-
- public function testConfiguration()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- /**
- * @param string $path
- */
- function ($path) {
- $xml = simplexml_load_file($path);
-
- $classes = \Magento\Framework\App\Utility\Classes::collectClassesInConfig($xml);
- $this->_assertNonFactoryName($classes, $path);
-
- $modules = \Magento\Framework\App\Utility\Classes::getXmlAttributeValues($xml, '//@module', 'module');
- $this->_assertNonFactoryName(array_unique($modules), $path, false, true);
- },
- Files::init()->getConfigFiles()
- );
- }
-
- public function testLayouts()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- /**
- * @param string $path
- */
- function ($path) {
- $xml = simplexml_load_file($path);
- $classes = \Magento\Framework\App\Utility\Classes::collectLayoutClasses($xml);
- foreach (\Magento\Framework\App\Utility\Classes::getXmlAttributeValues(
- $xml,
- '/layout//@helper',
- 'helper'
- ) as $class) {
- $classes[] = \Magento\Framework\App\Utility\Classes::getCallbackClass($class);
- }
- $classes = array_merge(
- $classes,
- \Magento\Framework\App\Utility\Classes::getXmlAttributeValues($xml, '/layout//@module', 'module')
- );
- $this->_assertNonFactoryName(array_unique($classes), $path);
-
- $tabs = \Magento\Framework\App\Utility\Classes::getXmlNodeValues(
- $xml,
- '/layout//action[@method="addTab"]/block'
- );
- $this->_assertNonFactoryName(array_unique($tabs), $path, true);
- },
- Files::init()->getLayoutFiles()
- );
- }
-
- /**
- * Check whether specified classes or module names correspond to a file according PSR-1 Standard.
- *
- * Suppressing "unused variable" because of the "catch" block
- *
- * @param array $names
- * @param bool $softComparison
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
- */
- protected function _assertNonFactoryName($names, $file, $softComparison = false, $moduleBlock = false)
- {
- if (!$names) {
- return;
- }
- $factoryNames = [];
- foreach ($names as $name) {
- try {
- if ($softComparison) {
- $this->assertDoesNotMatchRegularExpression('/\//', $name);
- } elseif ($moduleBlock) {
- $this->assertFalse(false === strpos($name, '_'));
- $this->assertMatchesRegularExpression('/^([A-Z][A-Za-z\d_]+)+$/', $name);
- } else {
- if (strpos($name, 'Magento') === false) {
- continue;
- }
- $this->assertFalse(false === strpos($name, '\\'));
- $this->assertMatchesRegularExpression('/^([A-Z\\\\][A-Za-z\d\\\\]+)+$/', $name);
- }
- } catch (\PHPUnit\Framework\AssertionFailedError $e) {
- $factoryNames[] = $name;
- }
- }
- if ($factoryNames) {
- $this->fail("Obsolete factory name(s) detected in {$file}:" . "\n" . implode("\n", $factoryNames));
- }
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/CopyrightTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/CopyrightTest.php
deleted file mode 100644
index 39f76583cf1ec..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/CopyrightTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-fail('Copyright is missing or has wrong format ' . $filename);
- }
- },
- $this->copyrightDataProvider()
- );
- }
-
- public function copyrightDataProvider()
- {
- $blackList = $this->getFilesData('blacklist*.php');
-
- $changedFiles = [];
- foreach (glob(__DIR__ . '/../_files/changed_files*') as $listFile) {
- $changedFiles = array_merge($changedFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
- }
- array_walk(
- $changedFiles,
- function (&$file) {
- $file = [BP . '/' . $file];
- }
- );
- $changedFiles = array_filter(
- $changedFiles,
- function ($path) use ($blackList) {
- if (!file_exists($path[0]) || !is_readable($path[0])) {
- return false;
- }
- $path[0] = realpath($path[0]);
- foreach ($blackList as $item) {
- if (preg_match($item, $path[0])) {
- return false;
- }
- }
- return true;
- }
- );
- return $changedFiles;
- }
-
- /**
- * @param string $filePattern
- * @return array
- */
- protected function getFilesData($filePattern)
- {
- $result = [];
- foreach (glob(__DIR__ . '/_files/copyright/' . $filePattern) as $file) {
- $fileData = include $file;
- $result = array_merge($result, $fileData);
- }
- return $result;
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
deleted file mode 100644
index dd2229968375e..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
+++ /dev/null
@@ -1,373 +0,0 @@
- [
- 'adminhtml.permissions.user.edit.tabs',
- 'adminhtml.permission.user.edit.tabs',
- 'adminhtml.permissions.user.edit',
- 'adminhtml.permission.user.edit',
- 'adminhtml.permissions.user.roles.grid.js',
- 'adminhtml.permission.user.roles.grid.js',
- 'adminhtml.permissions.user.edit.tab.roles',
- 'adminhtml.permissions.user.edit.tab.roles.js',
- ],
- 'adminhtml_user_role_index' => [
- 'adminhtml.permission.role.index',
- 'adminhtml.permissions.role.index',
- 'adminhtml.permissions.role.grid',
- ],
- 'adminhtml_user_role_rolegrid' => ['adminhtml.permission.role.grid', 'adminhtml.permissions.role.grid'],
- 'adminhtml_user_role_editrole' => [
- 'adminhtml.permissions.editroles',
- 'adminhtml.permissions.tab.rolesedit',
- 'adminhtml.permission.roles.users.grid.js',
- 'adminhtml.permissions.roles.users.grid.js',
- 'adminhtml.permission.role.buttons',
- 'adminhtml.permissions.role.buttons',
- 'adminhtml.permission.role.edit.gws',
- ],
- 'adminhtml_user_role_editrolegrid' => [
- 'adminhtml.permission.role.grid.user',
- 'adminhtml.permissions.role.grid.user',
- ],
- 'adminhtml_user_index' => ['adminhtml.permission.user.index', 'adminhtml.permissions.user.index'],
- 'adminhtml_user_rolegrid' => [
- 'adminhtml.permissions.user.rolegrid',
- 'adminhtml.permission.user.rolegrid',
- ],
- 'adminhtml_user_rolesgrid' => [
- 'adminhtml.permissions.user.rolesgrid',
- 'adminhtml.permission.user.rolesgrid',
- ],
- ];
-
- /**
- * @throws \Exception
- */
- public function testLayoutFile()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- /**
- * @param string $layoutFile
- */
- function ($layoutFile) {
- $layoutXml = simplexml_load_file($layoutFile);
-
- $this->_testObsoleteReferences($layoutXml);
- $this->_testObsoleteAttributes($layoutXml);
-
- $selectorHeadBlock = '(name()="block" or name()="referenceBlock") and ' .
- '(@name="head" or @name="convert_root_head" or @name="vde_head")';
- $this->assertSame(
- [],
- $layoutXml->xpath(
- '//block[@class="Magento\Theme\Block\Html\Head\Css" ' .
- 'or @class="Magento\Theme\Block\Html\Head\Link" ' .
- 'or @class="Magento\Theme\Block\Html\Head\Script"]' .
- '/parent::*[not(' .
- $selectorHeadBlock .
- ')]'
- ),
- 'Blocks \Magento\Theme\Block\Html\Head\{Css,Link,Script} ' .
- 'are allowed within the "head" block only. ' .
- 'Verify integrity of the nodes nesting.'
- );
- $this->assertSame(
- [],
- $layoutXml->xpath('/layout//*[@output="toHtml"]'),
- 'output="toHtml" is obsolete. Use output="1"'
- );
- foreach ($layoutXml as $handle) {
- $this->assertNotContains(
- (string)$handle['id'],
- $this->_obsoleteNodes,
- 'This layout handle is obsolete.'
- );
- }
- foreach ($layoutXml->xpath('@helper') as $action) {
- $this->assertNotContains('/', $action->getAttribute('helper'));
- $this->assertContains('::', $action->getAttribute('helper'));
- }
-
- $componentRegistrar = new ComponentRegistrar();
- if (false !== strpos(
- $layoutFile,
- $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Sales')
- . '/view/adminhtml/layout/sales_order'
- ) || false !== strpos(
- $layoutFile,
- $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Shipping')
- . '/view/adminhtml/layout/adminhtml_order'
- )
- || false !== strpos(
- $layoutFile,
- $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Catalog')
- . '/view/adminhtml/layout/catalog_product_grid.xml'
- )
- ) {
- $this->markTestIncomplete(
- "The file {$layoutFile} has to use \\Magento\\Core\\Block\\Text\\List, \n" .
- 'there is no solution to get rid of it right now.'
- );
- }
- $this->assertSame(
- [],
- $layoutXml->xpath('/layout//block[@class="Magento\Framework\View\Element\Text\ListText"]'),
- 'The class \Magento\Framework\View\Element\Text\ListTest' .
- ' is not supposed to be used in layout anymore.'
- );
- },
- \Magento\Framework\App\Utility\Files::init()->getLayoutFiles()
- );
- }
-
- /**
- * @param SimpleXMLElement $layoutXml
- */
- protected function _testObsoleteReferences($layoutXml)
- {
- foreach ($layoutXml as $handle) {
- if (isset($this->_obsoleteReferences[$handle->getName()])) {
- foreach ($handle->xpath('reference') as $reference) {
- $this->assertNotContains(
- (string)$reference['name'],
- $this->_obsoleteReferences[$handle->getName()],
- 'The block being referenced is removed.'
- );
- }
- }
- }
- }
-
- /**
- * Tests the attributes of the top-level Layout Node.
- * Verifies there are no longer attributes of "parent" or "owner"
- *
- * @param SimpleXMLElement $layoutXml
- */
- protected function _testObsoleteAttributes($layoutXml)
- {
- $issues = [];
- $type = $layoutXml['type'];
- $parent = $layoutXml['parent'];
- $owner = $layoutXml['owner'];
-
- if ((string)$type === 'page') {
- if ($parent) {
- $issues[] = 'Attribute "parent" is not valid';
- }
- }
- if ((string)$type === 'fragment') {
- if ($owner) {
- $issues[] = 'Attribute "owner" is not valid';
- }
- }
- if ($issues) {
- $this->fail("Issues found in handle declaration:\n" . implode("\n", $issues) . "\n");
- }
- }
-
- /**
- * @throws \Exception
- */
- public function testActionNodeMethods()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- /**
- * @param string $layoutFile
- */
- function ($layoutFile) {
- $layoutXml = simplexml_load_file($layoutFile);
- $methodFilter = '@method!="' . implode('" and @method!="', $this->getAllowedActionNodeMethods()) . '"';
- foreach ($layoutXml->xpath('//action[' . $methodFilter . ']') as $node) {
- $attributes = $node->attributes();
- $this->fail(
- sprintf(
- 'Call of method "%s" via layout instruction is not allowed.',
- $attributes['method']
- )
- );
- }
- },
- \Magento\Framework\App\Utility\Files::init()->getLayoutFiles()
- );
- }
-
- /**
- * List of currently allowed (i.e. not refactored yet) methods for use in layout
- * instruction.
- *
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- * Temporary method existing until instruction in layout is not eliminated, no need to split it.
- *
- * @return string[]
- */
- public function getAllowedActionNodeMethods()
- {
- return [
- 'addBodyClass',
- 'addButtons',
- 'addColumnCountLayoutDepend',
- 'addCrumb',
- 'addDatabaseBlock',
- 'addInputTypeTemplate',
- 'addNotice',
- 'addReportTypeOption',
- 'addTab',
- 'addTabAfter',
- 'addText',
- 'append',
- 'removeTab',
- 'setActive',
- 'setAddressType',
- 'setAfterCondition',
- 'setAfterTotal',
- 'setAtCall',
- 'setAtCode',
- 'setAtLabel',
- 'setAuthenticationStartMode',
- 'setBeforeCondition',
- 'setBlockId',
- 'setBugreportUrl',
- 'setCanLoadExtJs',
- 'setCanLoadRulesJs',
- 'setCanLoadTinyMce',
- 'setClassName',
- 'setColClass',
- 'setColumnCount',
- 'setColumnsLimit',
- 'setCssClass',
- 'setDefaultFilter',
- 'setDefaultStoreName',
- 'setDestElementId',
- 'setDisplayArea',
- 'setDontDisplayContainer',
- 'setEmptyGridMessage',
- 'setEntityModelClass',
- 'setFieldOption',
- 'setFieldVisibility',
- 'setFormCode',
- 'setFormId',
- 'setFormPrefix',
- 'setGiftRegistryTemplate',
- 'setGiftRegistryUrl',
- 'setGridHtmlClass',
- 'setGridHtmlCss',
- 'setGridHtmlId',
- 'setHeaderTitle',
- 'setHideBalance',
- 'setHideLink',
- 'setHideRequiredNotice',
- 'setHtmlClass',
- 'setId',
- 'setImageType',
- 'setImgAlt',
- 'setImgHeight',
- 'setImgSrc',
- 'setImgWidth',
- 'setInList',
- 'setInfoTemplate',
- 'setIsCollapsed',
- 'setIsDisabled',
- 'setIsEnabled',
- 'setIsGuestNote',
- 'setIsHandle',
- 'setIsLinkMode',
- 'setIsPlaneMode',
- 'setIsTitleHidden',
- 'setIsViewCurrent',
- 'setItemLimit',
- 'setLabel',
- 'setLabelProperties',
- 'setLayoutCode',
- 'setLinkUrl',
- 'setListCollection',
- 'setListModes',
- 'setListOrders',
- 'setMAPTemplate',
- 'setMethodFormTemplate',
- 'setMyClass',
- 'setPageLayout',
- 'setPageTitle',
- 'setParentType',
- 'setControllerPath',
- 'setPosition',
- 'setPositioned',
- 'setRewardMessage',
- 'setRewardQtyLimitationMessage',
- 'setShouldPrepareInfoTabs',
- 'setShowPart',
- 'setSignupLabel',
- 'setSourceField',
- 'setStoreVarName',
- 'setStrong',
- 'setTemplate',
- 'setText',
- 'setThemeName',
- 'setTierPriceTemplate',
- 'setTitle',
- 'setTitleClass',
- 'setTitleId',
- 'setToolbarBlockName',
- 'setType',
- 'setUseConfirm',
- 'setValueProperties',
- 'setViewAction',
- 'setViewColumn',
- 'setViewLabel',
- 'setViewMode',
- 'setWrapperClass',
- 'unsetChild',
- 'unsetChildren',
- 'updateButton',
- 'setIsProductListingContext',
- ];
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LicenseTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LicenseTest.php
deleted file mode 100644
index ed1410f73305b..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/LicenseTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-assertStringNotContainsString(
- $legacyText,
- $commentText,
- "The license of file {$filename} contains legacy text."
- );
- }
- }
- },
- $this->legacyCommentDataProvider()
- );
- }
-
- public function legacyCommentDataProvider()
- {
- $allFiles = \Magento\Framework\App\Utility\Files::init()->getAllFiles();
- $result = [];
- foreach ($allFiles as $file) {
- if (!file_exists($file[0]) || !is_readable($file[0])) {
- continue;
- }
- $result[] = [$file[0]];
- }
- return $result;
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Core/Block/AbstractBlockTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Core/Block/AbstractBlockTest.php
deleted file mode 100644
index 781023ec356a1..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Core/Block/AbstractBlockTest.php
+++ /dev/null
@@ -1,57 +0,0 @@
-getChildHtml\([^,()]+, ?[^,()]+,)/i"
- );
- $this->assertEmpty(
- $result,
- "3rd parameter is not needed anymore for getChildHtml() in '{$file}': " . print_r($result, true)
- );
- $result = \Magento\Framework\App\Utility\Classes::getAllMatches(
- file_get_contents($file),
- "/(->getChildChildHtml\([^,()]+, ?[^,()]+, ?[^,()]+,)/i"
- );
- $this->assertEmpty(
- $result,
- "4th parameter is not needed anymore for getChildChildHtml() in '{$file}': " . print_r(
- $result,
- true
- )
- );
- },
- Files::init()->getPhpFiles(
- Files::INCLUDE_APP_CODE
- | Files::INCLUDE_PUB_CODE
- | Files::INCLUDE_LIBS
- | Files::INCLUDE_TEMPLATES
- | Files::INCLUDE_TESTS
- | Files::AS_DATA_SET
- | Files::INCLUDE_NON_CLASSES
- )
- );
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteConnectionTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteConnectionTest.php
deleted file mode 100644
index 3ea9ff5c58dc9..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteConnectionTest.php
+++ /dev/null
@@ -1,152 +0,0 @@
-obsoleteMethods = [
- '_getReadConnection',
- '_getWriteConnection',
- '_getReadAdapter',
- '_getWriteAdapter',
- 'getReadConnection',
- 'getWriteConnection',
- 'getReadAdapter',
- 'getWriteAdapter',
- ];
-
- $this->obsoleteRegexp = [
- // 'getConnection\\(\'\\w*_*(read|write)',
- '\\$_?(read|write)(Connection|Adapter)',
- '\\$write([A-Z]\\w*|\\s)',
- ];
-
- $this->filesBlackList = $this->getBlackList();
- }
-
- /**
- * Test verify that obsolete regexps do not appear in refactored folders
- */
- public function testObsoleteRegexp()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- function ($file) {
- $content = file_get_contents($file);
- foreach ($this->obsoleteRegexp as $regexp) {
- $this->assertSame(
- 0,
- preg_match('/' . $regexp . '/iS', $content),
- "File: $file\nContains obsolete regexp: $regexp. "
- );
- }
- },
- $this->modulesFilesDataProvider()
- );
- }
-
- /**
- * Test verify that obsolete methods do not appear in refactored folders
- */
- public function testObsoleteResponseMethods()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- function ($file) {
- $content = file_get_contents($file);
- foreach ($this->obsoleteMethods as $method) {
- $quotedMethod = preg_quote($method, '/');
- $this->assertSame(
- 0,
- preg_match('/(?<=[a-z\\d_:]|->|function\\s)' . $quotedMethod . '\\s*\\(/iS', $content),
- "File: $file\nContains obsolete method: $method . "
- );
- }
- },
- $this->modulesFilesDataProvider()
- );
- }
-
- /**
- * Return refactored files
- *
- * @return array
- */
- public function modulesFilesDataProvider()
- {
- $filesList = [];
- $componentRegistrar = new ComponentRegistrar();
- foreach ($this->getFilesData('whitelist/refactored_modules*') as $refactoredModule) {
- if ($componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)) {
- $files = \Magento\Framework\App\Utility\Files::init()->getFiles(
- [$componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)],
- '*.php'
- );
- $filesList = array_merge($filesList, $files);
- }
- }
-
- $result = array_map('realpath', $filesList);
- $result = array_diff($result, $this->filesBlackList);
- return \Magento\Framework\App\Utility\Files::composeDataSets($result);
- }
-
- /**
- * @return array
- */
- protected function getBlackList()
- {
- $blackListFiles = [];
- $componentRegistrar = new ComponentRegistrar();
- foreach ($this->getFilesData('blacklist/files_list*') as $fileInfo) {
- $blackListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0])
- . DIRECTORY_SEPARATOR . $fileInfo[1];
- }
- return $blackListFiles;
- }
-
- /**
- * @param string $filePattern
- * @return array
- */
- protected function getFilesData($filePattern)
- {
- $result = [];
- foreach (glob(__DIR__ . '/_files/connection/' . $filePattern) as $file) {
- $fileData = include $file;
- $result = array_merge($result, $fileData);
- }
- return $result;
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteResponseTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteResponseTest.php
deleted file mode 100644
index 208d856e426ee..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteResponseTest.php
+++ /dev/null
@@ -1,110 +0,0 @@
-obsoleteMethods = include __DIR__ . '/_files/response/obsolete_response_methods.php';
- $this->filesBlackList = $this->getBlackList();
- }
-
- /**
- * Test verify that obsolete methods do not appear in refactored folders
- */
- public function testObsoleteResponseMethods()
- {
- $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
- $invoker(
- function ($file) {
- $content = file_get_contents($file);
- foreach ($this->obsoleteMethods as $method) {
- $quotedMethod = preg_quote($method, '/');
- $this->assertSame(
- 0,
- preg_match('/(?<=[a-z\\d_:]|->|function\\s)' . $quotedMethod . '\\s*\\(/iS', $content),
- "File: $file\nContains obsolete method: $method . "
- );
- }
- },
- $this->modulesFilesDataProvider()
- );
- }
-
- /**
- * Return refactored files
- *
- * @return array
- */
- public function modulesFilesDataProvider()
- {
- $filesList = [];
- $componentRegistrar = new ComponentRegistrar();
- foreach ($this->getFilesData('whitelist/refactored_modules*') as $refactoredModule) {
- if ($componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)) {
- $files = \Magento\Framework\App\Utility\Files::init()->getFiles(
- [$componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)],
- '*.php'
- );
- $filesList = array_merge($filesList, $files);
- }
- }
-
- $result = array_map('realpath', $filesList);
- $result = array_diff($result, $this->filesBlackList);
- return \Magento\Framework\App\Utility\Files::composeDataSets($result);
- }
-
- /**
- * @return array
- */
- protected function getBlackList()
- {
- $blackListFiles = [];
- $componentRegistrar = new ComponentRegistrar();
- foreach ($this->getFilesData('blacklist/files_list*') as $fileInfo) {
- $blackListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0])
- . DIRECTORY_SEPARATOR . $fileInfo[1];
- }
- return $blackListFiles;
- }
-
- /**
- * @param string $filePattern
- * @return array
- */
- protected function getFilesData($filePattern)
- {
- $result = [];
- foreach (glob(__DIR__ . '/_files/response/' . $filePattern) as $file) {
- $fileData = include $file;
- $result = array_merge($result, $fileData);
- }
- return $result;
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php
deleted file mode 100644
index c091c178a5bee..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php
+++ /dev/null
@@ -1,218 +0,0 @@
-(?!helper)\S*/iS',
- file_get_contents($file),
- 'Access to members and methods of Block class through $this is ' .
- 'obsolete in phtml templates. Use only $block instead of $this.'
- );
- },
- Files::init()->getPhtmlFiles()
- );
- }
-
- /**
- * @return void
- */
- public function testObsoleteBlockMethods(): void
- {
- $invoker = new AggregateInvoker($this);
- $invoker(
- /**
- * Test usage of protected and private methods and variables in template
- *
- * According to naming convention (B5.8, B6.2) all class members
- * in protected or private scope should be prefixed with underscore.
- * Member variables declared "public" should never start with an underscore.
- * Access to protected and private members of Block class is obsolete in phtml templates
- * since introduction of multiple template engines support
- *
- * @param string $file
- */
- function ($file) {
- self::assertDoesNotMatchRegularExpression(
- '/block->_[^_]+\S*\(/iS',
- file_get_contents($file),
- 'Access to protected and private members of Block class is ' .
- 'obsolete in phtml templates. Use only public members.'
- );
- },
- Files::init()->getPhtmlFiles()
- );
- }
-
- /**
- * @return void
- */
- public function testObsoleteJavascriptAttributeType(): void
- {
- $invoker = new AggregateInvoker($this);
- $invoker(
- /**
- * "text/javascript" type attribute in not obligatory to use in templates due to HTML5 standards.
- * For more details please go to "http://www.w3.org/TR/html5/scripting-1.html".
- *
- * @param string $file
- */
- function ($file) {
- self::assertDoesNotMatchRegularExpression(
- '/type="text\/javascript"/',
- file_get_contents($file),
- 'Please do not use "text/javascript" type attribute.'
- );
- },
- Files::init()->getPhtmlFiles()
- );
- }
-
- /**
- * @return void
- */
- public function testJqueryUiLibraryIsNotUsedInTemplates(): void
- {
- $invoker = new AggregateInvoker($this);
- $invoker(
- /**
- * 'jquery/ui' library is not obligatory to use in phtml files.
- * It's better to use needed jquery ui widget instead.
- *
- * @param string $file
- */
- function ($file) {
- if (strpos($file, '/view/frontend/templates/') !== false
- || strpos($file, '/view/base/templates/') !== false
- ) {
- self::assertDoesNotMatchRegularExpression(
- '/(["\'])jquery\/ui\1/',
- file_get_contents($file),
- 'Please do not use "jquery/ui" library in templates. Use needed jquery ui widget instead.'
- );
- }
- },
- Files::init()->getPhtmlFiles()
- );
- }
-
- /**
- * @return void
- */
- public function testJsComponentsAreProperlyInitializedInDataMageInitAttribute(): void
- {
- $invoker = new AggregateInvoker($this);
- $invoker(
- /**
- * JS components in data-mage-init attributes should be initialized not in php.
- * JS components should be initialized in templates for them to be properly statically analyzed for bundling.
- *
- * @param string $file
- */
- function ($file) {
- $whiteList = $this->getWhiteList();
- if (!in_array($file, $whiteList, true)
- && (strpos($file, '/view/frontend/templates/') !== false
- || strpos($file, '/view/base/templates/') !== false)
- ) {
- self::assertDoesNotMatchRegularExpression(
- '/data-mage-init=(?:\'|")(?!\s*{\s*"[^"]+")/',
- file_get_contents($file),
- 'Please do not initialize JS component in php. Do it in template.'
- );
- }
- },
- Files::init()->getPhtmlFiles()
- );
- }
-
- /**
- * @return array
- */
- private function getWhiteList(): array
- {
- $whiteListFiles = [];
- $componentRegistrar = new ComponentRegistrar();
-
- foreach ($this->getFilesData('data_mage_init/whitelist.php') as $fileInfo) {
- $whiteListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0])
- . DIRECTORY_SEPARATOR . $fileInfo[1];
- }
-
- return $whiteListFiles;
- }
-
- /**
- * @param string $filePattern
- *
- * @return array
- */
- private function getFilesData($filePattern): array
- {
- $result = [];
-
- foreach (glob(__DIR__ . '/_files/initialize_javascript/' . $filePattern) as $file) {
- $fileData = include $file;
- $result = array_merge($result, $fileData);
- }
-
- return $result;
- }
-
- /**
- * @return void
- */
- public function testJsComponentsAreProperlyInitializedInXMagentoInitAttribute(): void
- {
- $invoker = new AggregateInvoker($this);
- $invoker(
- /**
- * JS components in x-magento-init attributes should be initialized not in php.
- * JS components should be initialized in templates for them to be properly statically analyzed for bundling.
- *
- * @param string $file
- */
- function ($file) {
- if (strpos($file, '/view/frontend/templates/') !== false
- || strpos($file, '/view/base/templates/') !== false
- ) {
- self::assertDoesNotMatchRegularExpression(
- '@x-magento-init.>(?!\s*+{\s*"[^"]+"\s*:\s*{\s*"[\w/-]+")@i',
- file_get_contents($file),
- 'Please do not initialize JS component in php. Do it in template.'
- );
- }
- },
- Files::init()->getPhtmlFiles()
- );
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/TableTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/TableTest.php
deleted file mode 100644
index dd528a3b126f0..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/TableTest.php
+++ /dev/null
@@ -1,222 +0,0 @@
-_composeFoundsMessage($legacyTables);
- $this->assertEmpty($message, $message);
- },
- Files::init()->getPhpFiles(
- Files::INCLUDE_APP_CODE
- | Files::INCLUDE_PUB_CODE
- | Files::INCLUDE_LIBS
- | Files::INCLUDE_TEMPLATES
- | Files::AS_DATA_SET
- | Files::INCLUDE_NON_CLASSES
- )
- );
- }
-
- /**
- * Returns found table names in a file
- *
- * @param string $filePath
- * @return array
- */
- public static function extractTables($filePath)
- {
- $regexpMethods = ['_getRegexpTableInMethods', '_getRegexpTableInArrays', '_getRegexpTableInProperties'];
-
- $result = [];
- $content = file_get_contents($filePath);
- foreach ($regexpMethods as $method) {
- $regexp = self::$method($filePath);
- if (!preg_match_all($regexp, $content, $matches, PREG_SET_ORDER)) {
- continue;
- }
-
- $iterationResult = self::_matchesToInformation($content, $matches);
- $result = array_merge($result, $iterationResult);
- }
- return $result;
- }
-
- /**
- * Returns regexp to find table names in method calls in a file
- *
- * @param string $filePath
- * @return string
- */
- protected static function _getRegexpTableInMethods($filePath)
- {
- $methods = [
- 'getTableName',
- '_setMainTable',
- 'setMainTable',
- 'getTable',
- 'setTable',
- 'getTableRow',
- 'deleteTableRow',
- 'updateTableRow',
- 'updateTable',
- 'tableExists',
- ['name' => 'joinField', 'param_index' => 1],
- 'joinTable',
- 'getFkName',
- ['name' => 'getFkName', 'param_index' => 2],
- 'getIdxName',
- ['name' => 'addVirtualGridColumn', 'param_index' => 1],
- ];
-
- if (self::_isResourceButNotCollection($filePath)) {
- $methods[] = '_init';
- }
-
- $regexps = [];
- foreach ($methods as $method) {
- $regexps[] = self::_composeRegexpForMethod($method);
- }
- $result = '#->\s*(' . implode('|', $regexps) . ')#';
-
- return $result;
- }
-
- /**
- * @param string $filePath
- * @return bool
- */
- protected static function _isResourceButNotCollection($filePath)
- {
- $filePath = str_replace('\\', '/', $filePath);
- $parts = explode('/', $filePath);
- return array_search('Resource', $parts) !== false && array_search('Collection.php', $parts) === false;
- }
-
- /**
- * Returns regular expression to find legacy method calls with table in it
- *
- * @param string|array $method Method name, or array with method name and index of table parameter in signature
- * @return string
- */
- protected static function _composeRegexpForMethod($method)
- {
- if (!is_array($method)) {
- $method = ['name' => $method, 'param_index' => 0];
- }
-
- if ($method['param_index']) {
- $skipParamsRegexp = '\s*[[:alnum:]$_\'"]+\s*,';
- $skipParamsRegexp = str_repeat($skipParamsRegexp, $method['param_index']);
- } else {
- $skipParamsRegexp = '';
- }
-
- $result = $method['name'] . '\(' . $skipParamsRegexp . '\s*[\'"]([^\'"]+)';
- return $result;
- }
-
- /**
- * Returns regexp to find table names in array definitions
- *
- * @param string $filePath
- * @return string
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- protected static function _getRegexpTableInArrays($filePath)
- {
- return '/[\'"](?:[a-z\d_]+_)?table[\'"]\s*=>\s*[\'"]([^\'"]+)/';
- }
-
- /**
- * Returns regexp to find table names in property assignments
- *
- * @param string $filePath
- * @return string
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- protected static function _getRegexpTableInProperties($filePath)
- {
- $properties = ['_aggregationTable'];
-
- $regexps = [];
- foreach ($properties as $property) {
- $regexps[] = $property . '\s*=\s*[\'"]([^\'"]+)';
- }
- $result = '#' . implode('|', $regexps) . '#';
-
- return $result;
- }
-
- /**
- * Converts regexp matches to information, understandable by human: extracts legacy table name and line,
- * where it was found
- *
- * @param string $content
- * @param array $matches
- * @return array
- */
- protected static function _matchesToInformation($content, $matches)
- {
- $result = [];
- $fromPos = 0;
- foreach ($matches as $match) {
- $pos = strpos($content, $match[0], $fromPos);
- $lineNum = substr_count($content, "\n", 0, $pos) + 1;
- $result[] = ['name' => $match[count($match) - 1], 'line' => $lineNum];
- $fromPos = $pos + 1;
- }
- return $result;
- }
-
- /**
- * Composes information message based on list of legacy tables, found in a file
- *
- * @param array $legacyTables
- * @return string
- */
- protected function _composeFoundsMessage($legacyTables): string
- {
- if (!$legacyTables) {
- return '';
- }
-
- $descriptions = [];
- foreach ($legacyTables as $legacyTable) {
- $descriptions[] = "{$legacyTable['name']} (line {$legacyTable['line']})";
- }
-
- $result = 'Legacy table names with slash must be fixed to direct table names. Found: ' . implode(
- ', ',
- $descriptions
- ) . '.';
- return $result;
- }
-}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/autogenerated_class_not_in_constructor_whitelist.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/autogenerated_class_not_in_constructor_whitelist.php
deleted file mode 100644
index f8979ef6ab15e..0000000000000
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/autogenerated_class_not_in_constructor_whitelist.php
+++ /dev/null
@@ -1,14 +0,0 @@
- will be suggested to be used instead.
- * Use to specify files and directories that are allowed to use restricted classes.
- *
- * Format: array(, [, array()]])
- */
-return [
- 'Zend_Db_Select' => [
- 'replacement' => '\Magento\Framework\DB\Select',
- 'exclude' => [
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/Select.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/Adapter/Pdo/Mysql.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Model/ResourceModel/Iterator.php'
- ],
- ]
- ],
- 'Zend_Db_Adapter_Pdo_Mysql' => [
- 'replacement' => '\Magento\Framework\DB\Adapter\Pdo\Mysql',
- 'exclude' => [
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/Adapter/Pdo/Mysql.php'
- ],
- ]
- ],
- 'Magento\Framework\Serialize\Serializer\Serialize' => [
- 'replacement' => 'Magento\Framework\Serialize\SerializerInterface',
- 'exclude' => [
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'App/ObjectManager/ConfigLoader/Compiled.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'App/Config/ScopePool.php'],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'App/ObjectManager/ConfigCache.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'App/ObjectManager/ConfigLoader.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/Adapter/Pdo/Mysql.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/DataConverter/SerializedToJson.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'DB/Test/Unit/DataConverter/SerializedToJsonTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'ObjectManager/Config/Compiled.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Interception/Config/Config.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Interception/PluginList/PluginList.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'App/Router/ActionList.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Serialize/Test/Unit/Serializer/SerializeTest.php'
- ],
- [
- 'type' => 'setup',
- 'path' => 'src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Sales',
- 'path' => 'Setup/SerializedDataConverter.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Sales',
- 'path' => 'Test/Unit/Setup/SerializedDataConverterTest.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Sales',
- 'path' => 'Test/Unit/Setup/SalesOrderPaymentDataConverterTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Flag.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Widget',
- 'path' => 'Setup/LayoutUpdateConverter.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Cms',
- 'path' => 'Setup/ContentConverter.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Unserialize/Test/Unit/UnserializeTest.php'
- ],
- ]
- ],
- 'ArrayObject' => [
- 'replacement' => 'Custom class, extended from ArrayObject with overwritten serialize/unserialize methods',
- 'exclude' => [
- [
- 'type' => 'module',
- 'name' => 'Magento_Theme',
- 'path' => 'Model/Indexer/Design/Config.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Ui',
- 'path' => 'Model/Manager.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Ui',
- 'path' => 'Test/Unit/Model/ManagerTest.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Backend',
- 'path' => 'Model/Menu.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_CatalogSearch',
- 'path' => 'Model/Indexer/Fulltext.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_CatalogSearch',
- 'path' => 'Test/Unit/Model/Indexer/FulltextTest.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Catalog',
- 'path' => 'Test/Unit/Model/ProductTest.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_CatalogSearch',
- 'path' => 'Model/Indexer/Fulltext.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Test/Unit/FlagTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Validator/Test/Unit/Constraint/PropertyTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Indexer/Test/Unit/BatchTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'View/Element/UiComponent/ArrayObjectFactory.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'View/Element/UiComponent/Config/Provider/Component/Definition.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'Indexer/Action/Base.php'
- ]
- ]
- ],
- 'Magento\Framework\View\Element\UiComponent\ArrayObjectFactory' => [
- 'replacement' => 'Factory that creates custom class, extended from ArrayObject with overwritten '
- . 'serialize/unserialize methods',
- 'exclude' => [
- [
- 'type' => 'module',
- 'name' => 'Magento_Ui',
- 'path' => 'Model/Manager.php'
- ],
- [
- 'type' => 'module',
- 'name' => 'Magento_Ui',
- 'path' => 'Test/Unit/Model/ManagerTest.php'
- ],
- [
- 'type' => 'library',
- 'name' => 'magento/framework',
- 'path' => 'View/Element/UiComponent/Config/Provider/Component/Definition.php'
- ]
- ]
- ]
-];