From fe8f197cc080a6cc1ba57893a24e238e443fd7fa Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Fri, 24 May 2019 17:50:21 -0500 Subject: [PATCH 1/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test --- .../Magento/AdminNotification/composer.json | 3 +- .../Catalog/Block/Adminhtml/Category/Tree.php | 2 +- .../Customer/Block/Account/Dashboard.php | 7 +- app/code/Magento/Directory/Block/Data.php | 2 +- .../Payflow/Service/Request/SecureToken.php | 2 +- .../Magento/Review/Block/Adminhtml/Rss.php | 3 +- .../Magento/Sales/Block/Order/History.php | 5 +- app/code/Magento/Sales/Block/Order/Recent.php | 5 +- app/code/Magento/Store/composer.json | 3 +- app/code/Magento/Tinymce3/composer.json | 3 +- app/code/Magento/Ui/composer.json | 3 +- app/code/Magento/Variable/composer.json | 3 +- .../TestFramework/Dependency/PhpRule.php | 50 ++- .../Dependency/Route/RouteMapper.php | 332 ++++++++++++++++++ .../Magento/Test/Integrity/DependencyTest.php | 125 ++----- .../undetected_dependencies_ce.php | 10 - 16 files changed, 416 insertions(+), 142 deletions(-) create mode 100644 dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php delete mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/undetected_dependencies_ce.php diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index e5cf487908cd7..fe0727474fa25 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -11,7 +11,8 @@ "magento/module-backend": "*", "magento/module-media-storage": "*", "magento/module-store": "*", - "magento/module-ui": "*" + "magento/module-ui": "*", + "magento/module-config": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php index 83ec501592489..9a4a9fa768006 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php @@ -253,7 +253,7 @@ public function getLoadTreeUrl($expanded = null) */ public function getNodesUrl() { - return $this->getUrl('catalog/category/jsonTree'); + return $this->getUrl('catalog/category/tree'); } /** diff --git a/app/code/Magento/Customer/Block/Account/Dashboard.php b/app/code/Magento/Customer/Block/Account/Dashboard.php index fa9c8f98a8c2c..8e0f79d45770a 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard.php @@ -114,10 +114,13 @@ public function getAddressEditUrl($address) * Retrieve the Url for customer orders. * * @return string + * @deprecated Action does not exist */ public function getOrdersUrl() { - return $this->_urlBuilder->getUrl('customer/order/index', ['_secure' => true]); + //phpcs:ignore Magento2.Functions.DiscouragedFunction + trigger_error('Method is deprecated', E_USER_DEPRECATED); + return ''; } /** @@ -137,7 +140,7 @@ public function getReviewsUrl() */ public function getWishlistUrl() { - return $this->_urlBuilder->getUrl('customer/wishlist/index', ['_secure' => true]); + return $this->_urlBuilder->getUrl('wishlist/index', ['_secure' => true]); } /** diff --git a/app/code/Magento/Directory/Block/Data.php b/app/code/Magento/Directory/Block/Data.php index 333e9e03706b9..5ee5ef080bace 100644 --- a/app/code/Magento/Directory/Block/Data.php +++ b/app/code/Magento/Directory/Block/Data.php @@ -75,7 +75,7 @@ public function __construct( */ public function getLoadrRegionUrl() { - return $this->getUrl('directory/json/childRegion'); + return $this->getUrl('directory/json/countryRegion'); } /** diff --git a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php index 8a2825a16d33a..587372189f7ff 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php +++ b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php @@ -69,7 +69,7 @@ public function requestToken(Quote $quote) $request->setSecuretokenid($this->mathRandom->getUniqueHash()); $request->setReturnurl($this->url->getUrl('paypal/transparent/response')); $request->setErrorurl($this->url->getUrl('paypal/transparent/response')); - $request->setCancelurl($this->url->getUrl('paypal/transparent/cancel')); + $request->setCancelurl(''); $request->setDisablereceipt('TRUE'); $request->setSilenttran('TRUE'); diff --git a/app/code/Magento/Review/Block/Adminhtml/Rss.php b/app/code/Magento/Review/Block/Adminhtml/Rss.php index 7a935b656cdaf..5d370115ea25b 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rss.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rss.php @@ -45,10 +45,9 @@ public function __construct( */ public function getRssData() { - $newUrl = $this->getUrl('rss/catalog/review', ['_secure' => true, '_nosecret' => true]); $title = __('Pending product review(s)'); - $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8']; + $data = ['title' => $title, 'description' => $title, 'link' => '', 'charset' => 'UTF-8']; foreach ($this->rssModel->getProductCollection() as $item) { if ($item->getStoreId()) { diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index 80925f66fc83d..b7cc74382ded7 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -149,10 +149,13 @@ public function getViewUrl($order) /** * @param object $order * @return string + * @deprecated Action does not exist */ public function getTrackUrl($order) { - return $this->getUrl('sales/order/track', ['order_id' => $order->getId()]); + //phpcs:ignore Magento2.Functions.DiscouragedFunction + trigger_error('Method is deprecated', E_USER_DEPRECATED); + return ''; } /** diff --git a/app/code/Magento/Sales/Block/Order/Recent.php b/app/code/Magento/Sales/Block/Order/Recent.php index 7e5be0ebfbba2..c91e75c6a2185 100644 --- a/app/code/Magento/Sales/Block/Order/Recent.php +++ b/app/code/Magento/Sales/Block/Order/Recent.php @@ -116,10 +116,13 @@ public function getViewUrl($order) /** * @param object $order * @return string + * @deprecated Action does not exist */ public function getTrackUrl($order) { - return $this->getUrl('sales/order/track', ['order_id' => $order->getId()]); + //phpcs:ignore Magento2.Functions.DiscouragedFunction + trigger_error('Method is deprecated', E_USER_DEPRECATED); + return ''; } /** diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index ebaa32b95f48b..6f05d65e732fd 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -11,7 +11,8 @@ "magento/module-config": "*", "magento/module-directory": "*", "magento/module-media-storage": "*", - "magento/module-ui": "*" + "magento/module-ui": "*", + "magento/module-backend": "*" }, "suggest": { "magento/module-deploy": "*" diff --git a/app/code/Magento/Tinymce3/composer.json b/app/code/Magento/Tinymce3/composer.json index 52e980052a87f..9ea4c7b2f18ac 100644 --- a/app/code/Magento/Tinymce3/composer.json +++ b/app/code/Magento/Tinymce3/composer.json @@ -7,7 +7,8 @@ "magento/module-backend": "*", "magento/module-ui": "*", "magento/module-variable": "*", - "magento/module-widget": "*" + "magento/module-widget": "*", + "magento/module-cms": "*" }, "suggest": { diff --git a/app/code/Magento/Ui/composer.json b/app/code/Magento/Ui/composer.json index 296332e383509..d0d93abc6b1e4 100644 --- a/app/code/Magento/Ui/composer.json +++ b/app/code/Magento/Ui/composer.json @@ -11,7 +11,8 @@ "magento/module-backend": "*", "magento/module-eav": "*", "magento/module-store": "*", - "magento/module-user": "*" + "magento/module-user": "*", + "magento/module-cms": "*" }, "suggest": { "magento/module-config": "*" diff --git a/app/code/Magento/Variable/composer.json b/app/code/Magento/Variable/composer.json index 017fd312bbdf8..bacbf15729d24 100644 --- a/app/code/Magento/Variable/composer.json +++ b/app/code/Magento/Variable/composer.json @@ -9,7 +9,8 @@ "magento/framework": "*", "magento/module-backend": "*", "magento/module-store": "*", - "magento/module-config": "*" + "magento/module-config": "*", + "magento/module-ui": "*" }, "type": "magento2-module", "license": [ diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php index 800bba2a880bd..8fe6172a89834 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php @@ -8,7 +8,12 @@ namespace Magento\TestFramework\Dependency; use Magento\Framework\App\Utility\Files; +use Magento\Framework\UrlInterface; +use Magento\TestFramework\Dependency\Route\RouteMapper; +/** + * Rule to check the dependencies between modules based on references, getUrl and layout blocks + */ class PhpRule implements RuleInterface { /** @@ -34,7 +39,7 @@ class PhpRule implements RuleInterface * * @var array */ - protected $_mapRouters = []; + private $_mapRouters = []; /** * List of layout blocks @@ -59,11 +64,15 @@ class PhpRule implements RuleInterface ]; /** - * Constructor - * + * @var RouteMapper + */ + private $routeMapper; + + /** * @param array $mapRouters * @param array $mapLayoutBlocks * @param array $pluginMap + * @throws \Exception */ public function __construct(array $mapRouters, array $mapLayoutBlocks, array $pluginMap = []) { @@ -71,6 +80,7 @@ public function __construct(array $mapRouters, array $mapLayoutBlocks, array $pl $this->_mapLayoutBlocks = $mapLayoutBlocks; $this->_namespaces = implode('|', \Magento\Framework\App\Utility\Files::init()->getNamespaces()); $this->pluginMap = $pluginMap ?: null; + $this->routeMapper = new RouteMapper(); } /** @@ -81,6 +91,7 @@ public function __construct(array $mapRouters, array $mapLayoutBlocks, array $pl * @param string $file * @param string $contents * @return array + * @throws \Exception */ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) { @@ -95,7 +106,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) ); $dependenciesInfo = $this->considerCaseDependencies( $dependenciesInfo, - $this->_caseGetUrl($currentModule, $contents) + $this->_caseGetUrl($currentModule, $contents, $file) ); $dependenciesInfo = $this->considerCaseDependencies( $dependenciesInfo, @@ -111,6 +122,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) * @param string $file * @param string $contents * @return array + * @throws \Exception */ private function caseClassesAndIdentifiers($currentModule, $file, &$contents) { @@ -184,12 +196,14 @@ private function loadDiFiles() * Generate an array of plugin info * * @return array + * @throws \Exception */ private function loadPluginMap() { if (!$this->pluginMap) { foreach ($this->loadDiFiles() as $filepath) { $dom = new \DOMDocument(); + // phpcs:ignore Magento2.Functions.DiscouragedFunction $dom->loadXML(file_get_contents($filepath)); $typeNodes = $dom->getElementsByTagName('type'); /** @var \DOMElement $type */ @@ -214,6 +228,7 @@ private function loadPluginMap() * @param string $dependent * @param string $dependency * @return bool + * @throws \Exception */ private function isPluginDependency($dependent, $dependency) { @@ -239,10 +254,12 @@ private function isPluginDependency($dependent, $dependency) * @param $currentModule * @param $contents * @return array + * @throws \Exception */ protected function _caseGetUrl($currentModule, &$contents) { - $pattern = '/[\->:]+(?getUrl\([\'"](?[\w\/*]+)[\'"])/'; + $pattern = '#(\->|:)(?getUrl\(([\'"])(?[a-z0-9\-_]{3,})/' + .'(?[a-z0-9\-_]+)(/(?[a-z0-9\-_]+))?\3)#i'; $dependencies = []; if (!preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER)) { @@ -250,18 +267,17 @@ protected function _caseGetUrl($currentModule, &$contents) } foreach ($matches as $item) { - $router = str_replace('/', '\\', $item['router']); - if (isset($this->_mapRouters[$router])) { - $modules = $this->_mapRouters[$router]; - if (!in_array($currentModule, $modules)) { - foreach ($modules as $module) { - $dependencies[] = [ - 'module' => $module, - 'type' => RuleInterface::TYPE_HARD, - 'source' => $item['source'], - ]; - } - } + $modules = $this->routeMapper->getDependencyByRoutePath( + $item['route_id'], + $item['controller_name'], + $item['action_name'] ?? UrlInterface::DEFAULT_ACTION_NAME + ); + if (!in_array($currentModule, $modules)) { + $dependencies[] = [ + 'module' => implode(" || ", $modules), + 'type' => RuleInterface::TYPE_HARD, + 'source' => $item['source'], + ]; } } return $dependencies; diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php new file mode 100644 index 0000000000000..79f2c1336f23c --- /dev/null +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php @@ -0,0 +1,332 @@ + '{Route_Id}' => ['{Module_Name}'] + * ) + * + * @var array + */ + private $routers = []; + + /** + * List of routes.xml files by modules + * + * Format: array( + * '{Module_Name}' => ['{Filename}'] + * ) + * + * @var array + */ + private $routeConfigFiles = []; + + /** + * List of controllers actions + * + * Format: array( + * '{Router_Id}' => '{Route_Id}' => '{Controller_Name}' => '{Action_Name}' => [{'Module_Name'}] + * ) + * + * @var array + */ + private $actions = []; + + /** + * List of reserved words + * + * @see \Magento\Framework\App\Router\ActionList + * @var array + */ + private $reservedWords = [ + 'abstract' => 1, + 'and' => 1, + 'array' => 1, + 'as' => 1, + 'break' => 1, + 'callable' => 1, + 'case' => 1, + 'catch' => 1, + 'class' => 1, + 'clone' => 1, + 'const' => 1, + 'continue' => 1, + 'declare' => 1, + 'default' => 1, + 'die' => 1, + 'do' => 1, + 'echo' => 1, + 'else' => 1, + 'elseif' => 1, + 'empty' => 1, + 'enddeclare' => 1, + 'endfor' => 1, + 'endforeach' => 1, + 'endif' => 1, + 'endswitch' => 1, + 'endwhile' => 1, + 'eval' => 1, + 'exit' => 1, + 'extends' => 1, + 'final' => 1, + 'for' => 1, + 'foreach' => 1, + 'function' => 1, + 'global' => 1, + 'goto' => 1, + 'if' => 1, + 'implements' => 1, + 'include' => 1, + 'instanceof' => 1, + 'insteadof' => 1, + 'interface' => 1, + 'isset' => 1, + 'list' => 1, + 'namespace' => 1, + 'new' => 1, + 'or' => 1, + 'print' => 1, + 'private' => 1, + 'protected' => 1, + 'public' => 1, + 'require' => 1, + 'return' => 1, + 'static' => 1, + 'switch' => 1, + 'throw' => 1, + 'trait' => 1, + 'try' => 1, + 'unset' => 1, + 'use' => 1, + 'var' => 1, + 'while' => 1, + 'xor' => 1, + 'void' => 1, + ]; + + /** + * Provide routing declaration by router_id + * + * @param string $routerId + * @return array + * @throws \Exception + */ + public function getRoutes(string $routerId = ''): array + { + $routes = []; + if (!$routerId) { + foreach ($this->getRoutersMap() as $routesByRouterType) { + $routes = array_merge_recursive($routes, $routesByRouterType); + } + array_walk( + $routes, + function (&$modules) { + $modules = array_unique($modules); + } + ); + } else { + $routes = $this->getRoutersMap()[$routerId] ?? []; + } + return $routes; + } + + /** + * Provide dependencies for a specific URL path + * + * @param string $routeId + * @param string $controllerName + * @param string $actionName + * @return array + * @throws \Exception + */ + public function getDependencyByRoutePath( + string $routeId, + string $controllerName, + string $actionName = UrlInterface::DEFAULT_ACTION_NAME + ): array { + $routeId = strtolower($routeId); + $controllerName = strtolower($controllerName); + $actionName = strtolower($actionName); + + if (isset($this->reservedWords[$actionName])) { + $actionName .= 'action'; + } + + $dependencies = []; + foreach ($this->getRouterTypes() as $routerId) { + if (isset($this->getActionsMap()[$routerId][$routeId][$controllerName][$actionName])) { + $dependencies = array_merge( + $dependencies, + $this->getActionsMap()[$routerId][$routeId][$controllerName][$actionName] + ); + } + } + + if (empty($dependencies)) { + throw new NotFoundException(__('Invalid URL path: %1', implode('/', [$routeId, $controllerName, $actionName]))); + } + return $dependencies; + } + + /** + * Provide a list of router type + * + * @return array + * @throws \Exception + */ + private function getRouterTypes() + { + return array_keys($this->getActionsMap()); + } + + /** + * Provide routing declaration + * + * @return array + * @throws \Exception + */ + private function getRoutersMap() + { + if (empty($this->routers)) { + foreach ($this->getListRoutesXml() as $module => $configFiles) { + foreach ($configFiles as $configFile) { + $this->processConfigFile($module, $configFile); + } + } + } + + return $this->routers; + } + + /** + * Update routers map for the module basing on the routing config file + * + * @param string $module + * @param string $configFile + * + * @return void + */ + private function processConfigFile($module, $configFile) + { + // Read module's routes.xml file + $config = simplexml_load_file($configFile); + + $routers = $config->xpath("/config/router"); + foreach ($routers as $router) { + $routerId = (string)$router['id']; + foreach ($router->xpath('route') as $route) { + $routeId = (string)$route['id']; + if (!isset($this->routers[$routerId][$routeId])) { + $this->routers[$routerId][$routeId] = []; + } + if (!in_array($module, $this->routers[$routerId][$routeId])) { + $this->routers[$routerId][$routeId][] = $module; + } + } + } + } + + /** + * Prepare the list of routes.xml files (by modules) + * + * @throws \Exception + */ + private function getListRoutesXml() + { + if (empty($this->routeConfigFiles)) { + $files = Files::init()->getConfigFiles('*/routes.xml', [], false); + $pattern = '/(?[A-Z][a-z]+)[_\/\\\\](?[A-Z][a-zA-Z]+)/'; + foreach ($files as $file) { + if (preg_match($pattern, $file, $matches)) { + $module = $matches['namespace'] . '\\' . $matches['module']; + $this->routeConfigFiles[$module][] = $file; + } + } + } + return $this->routeConfigFiles; + } + + /** + * Provide a list of available actions + * + * @return array + * @throws \Exception + */ + private function getActionsMap(): array + { + if (empty($this->actions)) { + $files = Files::init()->getPhpFiles(Files::INCLUDE_APP_CODE); + $actionsMap = []; + foreach ($this->getRoutersMap() as $routerId => $routes) { + foreach ($routes as $routeId => $dependencies) { + $actionsMapPerArea[$routeId] = []; + foreach ($dependencies as $module) { + $moduleActions = $this->getModuleActionsMapping($module, $routerId, $files); + $actionsMapPerArea[$routeId] = + array_merge_recursive($actionsMapPerArea[$routeId], $moduleActions); + } + } + $actionsMap[$routerId] = $actionsMapPerArea; + } + $this->actions = $actionsMap; + } + + return $this->actions; + } + + /** + * Provide a list of available module actions by router_id + * + * @param $module + * @param $routerId + * @param array $files + * @return array + */ + private function getModuleActionsMapping($module, $routerId, array $files): array + { + $subdirectoryPattern = str_replace('\\', DIRECTORY_SEPARATOR, $module); + $subdirectoryPattern .= DIRECTORY_SEPARATOR . 'Controller/'; + if (array_search($routerId, [Area::AREA_ADMINHTML, Area::AREA_ADMIN], true) !== false) { + $subdirectoryPattern .= ucfirst(Area::AREA_ADMINHTML) . DIRECTORY_SEPARATOR; + } else { + $subdirectoryPattern .= '(?!' . ucfirst(Area::AREA_ADMINHTML) . ')'; + } + + $actions = preg_grep('~' . $subdirectoryPattern . '~', $files); + + $actionsPattern = '#' . $subdirectoryPattern . '(?\S+)/' + . '(?\w+)\.php$#'; + + $moduleActionsMapping = []; + foreach ($actions as $action) { + if (preg_match($actionsPattern, $action, $matches)) { + $controllerName = strtolower(str_replace('/', '_', $matches['controller'])); + $actionName = strtolower($matches['action_name']); + if (!isset($moduleActionsMapping[$controllerName][$actionName])) { + $moduleActionsMapping[$controllerName][$actionName] = []; + } + $moduleActionsMapping[$controllerName][$actionName][] = $module; + } + } + + return $moduleActionsMapping; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php index 9c03802602938..d77ff4ea5a4ec 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php @@ -17,6 +17,7 @@ use Magento\TestFramework\Dependency\PhpRule; use Magento\TestFramework\Dependency\ReportsConfigRule; use Magento\TestFramework\Dependency\AnalyticsConfigRule; +use Magento\TestFramework\Dependency\Route\RouteMapper; use Magento\TestFramework\Dependency\VirtualType\VirtualTypeMapper; /** @@ -66,17 +67,6 @@ class DependencyTest extends \PHPUnit\Framework\TestCase */ protected static $_listConfigXml = []; - /** - * List of routes.xml files by modules - * - * Format: array( - * '{Module_Name}' => '{Filename}' - * ) - * - * @var array - */ - protected static $_listRoutesXml = []; - /** * List of analytics.xml * @@ -88,17 +78,6 @@ class DependencyTest extends \PHPUnit\Framework\TestCase */ protected static $_listAnalyticsXml = []; - /** - * List of routers - * - * Format: array( - * '{Router}' => '{Module_Name}' - * ) - * - * @var array - */ - protected static $_mapRouters = []; - /** * List of layout blocks * @@ -167,8 +146,15 @@ class DependencyTest extends \PHPUnit\Framework\TestCase */ private static $whiteList = []; + /** + * @var RouteMapper + */ + private static $routeMapper = null; + /** * Sets up data + * + * @throws \Exception */ public static function setUpBeforeClass() { @@ -181,13 +167,12 @@ public static function setUpBeforeClass() ); } + self::$routeMapper = new RouteMapper(); self::$_namespaces = implode('|', Files::init()->getNamespaces()); self::_prepareListConfigXml(); - self::_prepareListRoutesXml(); self::_prepareListAnalyticsXml(); - self::_prepareMapRouters(); self::_prepareMapLayoutBlocks(); self::_prepareMapLayoutHandles(); @@ -232,20 +217,23 @@ protected static function _initThemes() /** * Create rules objects + * + * @throws \Exception */ protected static function _initRules() { - $replaceFilePattern = str_replace('\\', '/', realpath(__DIR__)) . '/_files/dependency_test/tables_*.php'; + $replaceFilePattern = str_replace('\\', '/', realpath(__DIR__)) + . '/_files/dependency_test/tables_*.php'; $dbRuleTables = []; foreach (glob($replaceFilePattern) as $fileName) { //phpcs:ignore Generic.PHP.NoSilencedErrors $dbRuleTables = array_merge($dbRuleTables, @include $fileName); } self::$_rulesInstances = [ - new PhpRule(self::$_mapRouters, self::$_mapLayoutBlocks), + new PhpRule(self::$routeMapper->getRoutes(), self::$_mapLayoutBlocks), new DbRule($dbRuleTables), new LayoutRule( - self::$_mapRouters, + self::$routeMapper->getRoutes(), self::$_mapLayoutBlocks, self::$_mapLayoutHandles ), @@ -298,6 +286,7 @@ function ($matches) use ($contents, &$contentsWithoutHtml) { /** * @inheritdoc + * @throws \Exception */ public function testUndeclared() { @@ -440,13 +429,6 @@ public function collectRedundant() { $schemaDependencyProvider = new DeclarativeSchemaDependencyProvider(); - /** TODO: Remove this temporary solution after MC-5806 is closed */ - $filePattern = __DIR__ . '/_files/dependency_test/undetected_dependencies_*.php'; - $undetectedDependencies = []; - foreach (glob($filePattern) as $fileName) { - $undetectedDependencies = array_merge($undetectedDependencies, require $fileName); - } - foreach (array_keys(self::$mapDependencies) as $module) { $declared = $this->_getDependencies($module, self::TYPE_HARD, self::MAP_TYPE_DECLARED); $found = array_merge( @@ -454,10 +436,6 @@ public function collectRedundant() $this->_getDependencies($module, self::TYPE_SOFT, self::MAP_TYPE_FOUND), $schemaDependencyProvider->getDeclaredExistingModuleDependencies($module) ); - /** TODO: Remove this temporary solution after MC-5806 is closed */ - if (!empty($undetectedDependencies[$module])) { - $found = array_merge($found, $undetectedDependencies[$module]); - } $found['Magento\Framework'] = 'Magento\Framework'; $this->_setDependencies($module, self::TYPE_HARD, self::MAP_TYPE_REDUNDANT, array_diff($declared, $found)); @@ -557,6 +535,8 @@ public function getAllFiles() /** * Prepare list of config.xml files (by modules). + * + * @throws \Exception */ protected static function _prepareListConfigXml() { @@ -569,22 +549,10 @@ protected static function _prepareListConfigXml() } } - /** - * Prepare list of routes.xml files (by modules) - */ - protected static function _prepareListRoutesXml() - { - $files = Files::init()->getConfigFiles('*/routes.xml', [], false); - foreach ($files as $file) { - if (preg_match('/(?[A-Z][a-z]+)[_\/\\\\](?[A-Z][a-zA-Z]+)/', $file, $matches)) { - $module = $matches['namespace'] . '\\' . $matches['module']; - self::$_listRoutesXml[$module][] = $file; - } - } - } - /** * Prepare list of analytics.xml files + * + * @throws \Exception */ protected static function _prepareListAnalyticsXml() { @@ -597,57 +565,10 @@ protected static function _prepareListAnalyticsXml() } } - /** - * Prepare map of routers - */ - protected static function _prepareMapRouters() - { - $pattern = '/(?[A-Z][a-z]+)[_\/\\\\](?[A-Z][a-zA-Z]+)\/Controller\/' . - '(?[\/\w]*).php/'; - - $files = Files::init()->getPhpFiles(Files::INCLUDE_APP_CODE | Files::INCLUDE_NON_CLASSES); - foreach ($files as $file) { - if (preg_match($pattern, $file, $matches)) { - $module = $matches['namespace'] . '\\' . $matches['module']; - if (!empty(self::$_listRoutesXml[$module])) { - foreach (self::$_listRoutesXml[$module] as $configFile) { - self::updateRoutersMap($module, $configFile); - } - } - } - } - } - - /** - * Update routers map for the module basing on the routing config file - * - * @param string $module - * @param string $configFile - * - * @return void - */ - private static function updateRoutersMap($module, $configFile) - { - // Read module's routes.xml file - $config = simplexml_load_file($configFile); - $nodes = $config->xpath("/config/router/*"); - foreach ($nodes as $node) { - $id = (string)$node['id']; - if ($id != 'adminhtml' && '' == (string)$node['frontName']) { - // Exclude overridden routers - continue; - } - if (!isset(self::$_mapRouters[$id])) { - self::$_mapRouters[$id] = []; - } - if (!in_array($module, self::$_mapRouters[$id])) { - self::$_mapRouters[$id][] = $module; - } - } - } - /** * Prepare map of layout blocks + * + * @throws \Exception */ protected static function _prepareMapLayoutBlocks() { @@ -676,6 +597,8 @@ protected static function _prepareMapLayoutBlocks() /** * Prepare map of layout handles + * + * @throws \Exception */ protected static function _prepareMapLayoutHandles() { diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/undetected_dependencies_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/undetected_dependencies_ce.php deleted file mode 100644 index 407f57ee51257..0000000000000 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/undetected_dependencies_ce.php +++ /dev/null @@ -1,10 +0,0 @@ - ["Magento\CatalogSearch"] -]; From d18aefbb766a42512a9dc249204e932a638a8cf6 Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Mon, 3 Jun 2019 16:27:06 -0500 Subject: [PATCH 2/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test --- .../Catalog/Block/Adminhtml/Product/Grid.php | 26 ++--- .../adminhtml/layout/catalog_product_grid.xml | 4 +- .../Checkout/Controller/Onepage/SaveOrder.php | 2 +- .../Magento/Review/Block/Adminhtml/Rss.php | 24 ++-- .../Magento/Sales/Block/Order/History.php | 20 +++- app/code/Magento/Sales/Block/Order/Recent.php | 11 +- .../TestFramework/Dependency/PhpRule.php | 103 +++++++++++------ .../Dependency/Route/RouteMapper.php | 18 +-- .../Exception/NoSuchActionException.php | 16 +++ .../Magento/Test/Integrity/DependencyTest.php | 108 +++++++++++++++--- .../dependency_test/whitelist/routes_ce.php | 10 ++ 11 files changed, 257 insertions(+), 85 deletions(-) create mode 100644 dev/tests/static/framework/Magento/TestFramework/Exception/NoSuchActionException.php create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/whitelist/routes_ce.php diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 8f3a0793cc49f..6774d5df3cd91 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -85,7 +85,7 @@ public function __construct( } /** - * @return void + * @inheritDoc */ protected function _construct() { @@ -99,7 +99,10 @@ protected function _construct() } /** + * Get store + * * @return Store + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function _getStore() { @@ -108,7 +111,7 @@ protected function _getStore() } /** - * @return $this + * @inheritDoc */ protected function _prepareCollection() { @@ -136,7 +139,6 @@ protected function _prepareCollection() ); } if ($store->getId()) { - //$collection->setStoreId($store->getId()); $collection->addStoreFilter($store); $collection->joinAttribute( 'name', @@ -187,8 +189,7 @@ protected function _prepareCollection() } /** - * @param \Magento\Backend\Block\Widget\Grid\Column $column - * @return $this + * @inheritDoc */ protected function _addColumnFilterToCollection($column) { @@ -208,8 +209,9 @@ protected function _addColumnFilterToCollection($column) } /** - * @return $this + * @inheritDoc * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @throws \Exception */ protected function _prepareColumns() { @@ -364,16 +366,11 @@ protected function _prepareColumns() ] ); - $block = $this->getLayout()->getBlock('grid.bottom.links'); - if ($block) { - $this->setChild('grid.bottom.links', $block); - } - return parent::_prepareColumns(); } /** - * @return $this + * @inheritDoc */ protected function _prepareMassaction() { @@ -425,7 +422,7 @@ protected function _prepareMassaction() } /** - * @return string + * @inheritDoc */ public function getGridUrl() { @@ -433,8 +430,7 @@ public function getGridUrl() } /** - * @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $row - * @return string + * @inheritDoc */ public function getRowUrl($row) { diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_grid.xml b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_grid.xml index b42a78dfbe302..5d57c2d8f861a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_grid.xml +++ b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_grid.xml @@ -8,6 +8,8 @@ - + + + diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index 12b725a8f6df9..27d272330a8d2 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -31,7 +31,7 @@ public function execute() $result = new DataObject(); try { $agreementsValidator = $this->_objectManager->get( - \Magento\CheckoutAgreements\Model\AgreementsValidator::class + \Magento\Checkout\Api\AgreementsValidatorInterface::class ); if (!$agreementsValidator->isValid(array_keys($this->getRequest()->getPost('agreement', [])))) { $result->setData('success', false); diff --git a/app/code/Magento/Review/Block/Adminhtml/Rss.php b/app/code/Magento/Review/Block/Adminhtml/Rss.php index 5d370115ea25b..fd5737d218427 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rss.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rss.php @@ -9,6 +9,7 @@ /** * Class Rss + * * @package Magento\Catalog\Block\Adminhtml\Rss */ class Rss extends \Magento\Backend\Block\AbstractBlock implements DataProviderInterface @@ -41,7 +42,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritDoc */ public function getRssData() { @@ -55,11 +56,14 @@ public function getRssData() } $url = $this->getUrl('catalog/product/view', ['id' => $item->getId()]); - $reviewUrl = $this->getUrl('review/product/edit/', [ - 'id' => $item->getReviewId(), - '_secure' => true, - '_nosecret' => true - ]); + $reviewUrl = $this->getUrl( + 'review/product/edit/', + [ + 'id' => $item->getReviewId(), + '_secure' => true, + '_nosecret' => true + ] + ); $storeName = $this->storeManager->getStore($item->getStoreId())->getName(); $description = '

' . __('Product: %2
', $url, $item->getName()) @@ -79,7 +83,7 @@ public function getRssData() } /** - * {@inheritdoc} + * @inheritDoc */ public function getCacheLifetime() { @@ -87,7 +91,7 @@ public function getCacheLifetime() } /** - * {@inheritdoc} + * @inheritDoc */ public function isAllowed() { @@ -95,7 +99,7 @@ public function isAllowed() } /** - * {@inheritdoc} + * @inheritDoc */ public function getFeeds() { @@ -103,7 +107,7 @@ public function getFeeds() } /** - * {@inheritdoc} + * @inheritDoc */ public function isAuthRequired() { diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index b7cc74382ded7..c06a5d8b24c1e 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -67,7 +67,7 @@ public function __construct( } /** - * @return void + * @inheritDoc */ protected function _construct() { @@ -76,8 +76,9 @@ protected function _construct() } /** - * @return CollectionFactoryInterface + * Provide order collection factory * + * @return CollectionFactoryInterface * @deprecated 100.1.1 */ private function getOrderCollectionFactory() @@ -89,6 +90,8 @@ private function getOrderCollectionFactory() } /** + * Get customer orders + * * @return bool|\Magento\Sales\Model\ResourceModel\Order\Collection */ public function getOrders() @@ -111,7 +114,7 @@ public function getOrders() } /** - * @return $this + * @inheritDoc */ protected function _prepareLayout() { @@ -130,6 +133,8 @@ protected function _prepareLayout() } /** + * Get Pager child block output + * * @return string */ public function getPagerHtml() @@ -138,6 +143,8 @@ public function getPagerHtml() } /** + * Get order view URL + * * @param object $order * @return string */ @@ -147,9 +154,12 @@ public function getViewUrl($order) } /** + * Get order track URL + * * @param object $order * @return string * @deprecated Action does not exist + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getTrackUrl($order) { @@ -159,6 +169,8 @@ public function getTrackUrl($order) } /** + * Get reorder URL + * * @param object $order * @return string */ @@ -168,6 +180,8 @@ public function getReorderUrl($order) } /** + * Get customer account URL + * * @return string */ public function getBackUrl() diff --git a/app/code/Magento/Sales/Block/Order/Recent.php b/app/code/Magento/Sales/Block/Order/Recent.php index c91e75c6a2185..79119c1851347 100644 --- a/app/code/Magento/Sales/Block/Order/Recent.php +++ b/app/code/Magento/Sales/Block/Order/Recent.php @@ -71,7 +71,7 @@ public function __construct( } /** - * @return void + * @inheritDoc */ protected function _construct() { @@ -105,6 +105,8 @@ private function getRecentOrders() } /** + * Get order view URL + * * @param object $order * @return string */ @@ -114,9 +116,12 @@ public function getViewUrl($order) } /** + * Get order track URL + * * @param object $order * @return string * @deprecated Action does not exist + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getTrackUrl($order) { @@ -126,7 +131,7 @@ public function getTrackUrl($order) } /** - * @return string + * @inheritDoc */ protected function _toHtml() { @@ -137,6 +142,8 @@ protected function _toHtml() } /** + * Get reorder URL + * * @param object $order * @return string */ diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php index 8fe6172a89834..f4131c4c7d834 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php @@ -5,11 +5,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\TestFramework\Dependency; use Magento\Framework\App\Utility\Files; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\UrlInterface; use Magento\TestFramework\Dependency\Route\RouteMapper; +use Magento\TestFramework\Exception\NoSuchActionException; /** * Rule to check the dependencies between modules based on references, getUrl and layout blocks @@ -68,19 +72,32 @@ class PhpRule implements RuleInterface */ private $routeMapper; + /** + * Whitelists for dependency check + * + * @var array + */ + private $whitelists; + /** * @param array $mapRouters * @param array $mapLayoutBlocks * @param array $pluginMap + * @param array $whitelists * @throws \Exception */ - public function __construct(array $mapRouters, array $mapLayoutBlocks, array $pluginMap = []) - { + public function __construct( + array $mapRouters, + array $mapLayoutBlocks, + array $pluginMap = [], + array $whitelists = [] + ) { $this->_mapRouters = $mapRouters; $this->_mapLayoutBlocks = $mapLayoutBlocks; $this->_namespaces = implode('|', \Magento\Framework\App\Utility\Files::init()->getNamespaces()); $this->pluginMap = $pluginMap ?: null; $this->routeMapper = new RouteMapper(); + $this->whitelists = $whitelists; } /** @@ -106,7 +123,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) ); $dependenciesInfo = $this->considerCaseDependencies( $dependenciesInfo, - $this->_caseGetUrl($currentModule, $contents, $file) + $this->_caseGetUrl($currentModule, $contents) ); $dependenciesInfo = $this->considerCaseDependencies( $dependenciesInfo, @@ -115,6 +132,16 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) return $dependenciesInfo; } + /** + * Get routes whitelist + * + * @return array + */ + private function getRoutesWhitelist(): array + { + return $this->whitelists['routes'] ?? []; + } + /** * Check references to classes and identifiers defined in other modules * @@ -181,6 +208,8 @@ private function getClassFromFilepath($filepath, $module) } /** + * Load DI configuration files + * * @return array * @throws \Exception */ @@ -251,48 +280,56 @@ private function isPluginDependency($dependent, $dependency) * * Ex.: getUrl('{path}') * - * @param $currentModule - * @param $contents + * @param string $currentModule + * @param string $contents * @return array + * @throws LocalizedException * @throws \Exception */ - protected function _caseGetUrl($currentModule, &$contents) + protected function _caseGetUrl(string $currentModule, string &$contents): array { - $pattern = '#(\->|:)(?getUrl\(([\'"])(?[a-z0-9\-_]{3,})/' - .'(?[a-z0-9\-_]+)(/(?[a-z0-9\-_]+))?\3)#i'; + $pattern = '#(\->|:)(?getUrl\(([\'"])(?[a-z0-9\-_]{3,})' + .'(/(?[a-z0-9\-_]+))?(/(?[a-z0-9\-_]+))?\3)#i'; $dependencies = []; if (!preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER)) { return $dependencies; } - foreach ($matches as $item) { - $modules = $this->routeMapper->getDependencyByRoutePath( - $item['route_id'], - $item['controller_name'], - $item['action_name'] ?? UrlInterface::DEFAULT_ACTION_NAME - ); - if (!in_array($currentModule, $modules)) { - $dependencies[] = [ - 'module' => implode(" || ", $modules), - 'type' => RuleInterface::TYPE_HARD, - 'source' => $item['source'], - ]; + try { + foreach ($matches as $item) { + $modules = $this->routeMapper->getDependencyByRoutePath( + $item['route_id'], + $item['controller_name'] ?? UrlInterface::DEFAULT_CONTROLLER_NAME, + $item['action_name'] ?? UrlInterface::DEFAULT_ACTION_NAME + ); + if (!in_array($currentModule, $modules)) { + $dependencies[] = [ + 'module' => $modules, + 'type' => RuleInterface::TYPE_HARD, + 'source' => $item['source'], + ]; + } + } + } catch (NoSuchActionException $e) { + if (array_search($e->getMessage(), $this->getRoutesWhitelist()) === false) { + throw new LocalizedException(__('Invalid URL path: %1', $e->getMessage()), $e); } } + return $dependencies; } /** * Check layout blocks * - * @param $currentModule - * @param $fileType - * @param $file - * @param $contents + * @param string $currentModule + * @param string $fileType + * @param string $file + * @param string $contents * @return array */ - protected function _caseLayoutBlock($currentModule, $fileType, $file, &$contents) + protected function _caseLayoutBlock(string $currentModule, string $fileType, string $file, string &$contents): array { $pattern = '/[\->:]+(?(?:getBlock|getBlockHtml)\([\'"](?[\w\.\-]+)[\'"]\))/'; @@ -322,11 +359,11 @@ protected function _caseLayoutBlock($currentModule, $fileType, $file, &$contents /** * Get area from file path * - * @param $file - * @param $fileType + * @param string $file + * @param string $fileType * @return string|null */ - protected function _getAreaByFile($file, $fileType) + protected function _getAreaByFile(string $file, string $fileType): ?string { if ($fileType == 'php') { return null; @@ -346,12 +383,12 @@ protected function _getAreaByFile($file, $fileType) * 'source' // source text * ) * - * @param $currentModule - * @param $area - * @param $block + * @param string $currentModule + * @param string|null $area + * @param string $block * @return array */ - protected function _checkDependencyLayoutBlock($currentModule, $area, $block) + protected function _checkDependencyLayoutBlock(string $currentModule, ?string $area, string $block): array { if (isset($this->_mapLayoutBlocks[$area][$block]) || $area === null) { // CASE 1: No dependencies @@ -412,6 +449,8 @@ protected function _getUniqueDependencies($dependencies = []) } /** + * Merge dependencies + * * @param array $known * @param array $new * @return array diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php index 79f2c1336f23c..a3e5b6927e72a 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php @@ -9,8 +9,7 @@ use Magento\Framework\App\Area; use Magento\Framework\App\Utility\Files; -use Magento\Framework\Exception\NotFoundException; -use Magento\Framework\UrlInterface; +use Magento\TestFramework\Exception\NoSuchActionException; /** * Route mapper based on routes.xml declarations @@ -155,12 +154,13 @@ function (&$modules) { * @param string $controllerName * @param string $actionName * @return array + * @throws NoSuchActionException * @throws \Exception */ public function getDependencyByRoutePath( string $routeId, string $controllerName, - string $actionName = UrlInterface::DEFAULT_ACTION_NAME + string $actionName ): array { $routeId = strtolower($routeId); $controllerName = strtolower($controllerName); @@ -181,7 +181,9 @@ public function getDependencyByRoutePath( } if (empty($dependencies)) { - throw new NotFoundException(__('Invalid URL path: %1', implode('/', [$routeId, $controllerName, $actionName]))); + throw new NoSuchActionException(implode('/', [$routeId, $controllerName, $actionName])); + } else { + $dependencies = array_unique($dependencies); } return $dependencies; } @@ -224,7 +226,7 @@ private function getRoutersMap() * * @return void */ - private function processConfigFile($module, $configFile) + private function processConfigFile(string $module, string $configFile) { // Read module's routes.xml file $config = simplexml_load_file($configFile); @@ -295,12 +297,12 @@ private function getActionsMap(): array /** * Provide a list of available module actions by router_id * - * @param $module - * @param $routerId + * @param string $module + * @param string $routerId * @param array $files * @return array */ - private function getModuleActionsMapping($module, $routerId, array $files): array + private function getModuleActionsMapping(string $module, string $routerId, array $files): array { $subdirectoryPattern = str_replace('\\', DIRECTORY_SEPARATOR, $module); $subdirectoryPattern .= DIRECTORY_SEPARATOR . 'Controller/'; diff --git a/dev/tests/static/framework/Magento/TestFramework/Exception/NoSuchActionException.php b/dev/tests/static/framework/Magento/TestFramework/Exception/NoSuchActionException.php new file mode 100644 index 0000000000000..5ce432f8a183e --- /dev/null +++ b/dev/tests/static/framework/Magento/TestFramework/Exception/NoSuchActionException.php @@ -0,0 +1,16 @@ +getRoutes(), self::$_mapLayoutBlocks), + new PhpRule( + self::$routeMapper->getRoutes(), + self::$_mapLayoutBlocks, + [], + ['routes' => self::getRoutesWhitelist()] + ), new DbRule($dbRuleTables), new LayoutRule( self::$routeMapper->getRoutes(), @@ -243,6 +256,25 @@ protected static function _initRules() ]; } + /** + * Initialize routes whitelist + * + * @return array + */ + private static function getRoutesWhitelist(): array + { + if (is_null(self::$routesWhitelist)) { + $routesWhitelistFilePattern = realpath(__DIR__) . '/_files/dependency_test/whitelist/routes_*.php'; + $routesWhitelist = []; + foreach (glob($routesWhitelistFilePattern) as $fileName) { + $routesWhitelist = array_merge($routesWhitelist, include $fileName); + } + self::$routesWhitelist = $routesWhitelist; + } + + return self::$routesWhitelist; + } + /** * Return cleaned file contents * @@ -256,7 +288,8 @@ protected function _getCleanedFileContents($fileType, $file) switch ($fileType) { case 'php': //Removing php comments - $contents = preg_replace('~/\*.*?\*/~s', '', $contents); + $contents = preg_replace('~/\*.*?\*/~m', '', $contents); + $contents = preg_replace('~^\s*/\*.*?\*/~sm', '', $contents); $contents = preg_replace('~^\s*//.*$~m', '', $contents); break; case 'layout': @@ -351,6 +384,7 @@ function ($fileType, $file) { * @param string $file * @param string $contents * @return string[] + * @throws LocalizedException */ protected function getDependenciesFromFiles($module, $fileType, $file, $contents) { @@ -361,6 +395,7 @@ protected function getDependenciesFromFiles($module, $fileType, $file, $contents $newDependencies = $rule->getDependencyInfo($module, $fileType, $file, $contents); $dependencies = array_merge($dependencies, $newDependencies); } + foreach ($dependencies as $key => $dependency) { foreach (self::$whiteList as $namespace) { if (strpos($dependency['source'], $namespace) !== false) { @@ -400,21 +435,64 @@ protected function _collectDependencies($currentModuleName, $dependencies = []) */ private function collectDependency($dependency, $currentModule, &$undeclared) { - $module = $dependency['module']; - $nsModule = str_replace('_', '\\', $module); $type = isset($dependency['type']) ? $dependency['type'] : self::TYPE_HARD; $soft = $this->_getDependencies($currentModule, self::TYPE_SOFT, self::MAP_TYPE_DECLARED); $hard = $this->_getDependencies($currentModule, self::TYPE_HARD, self::MAP_TYPE_DECLARED); $declared = $type == self::TYPE_SOFT ? array_merge($soft, $hard) : $hard; - if (!in_array($module, $declared) && !in_array($nsModule, $declared) && !$this->_isFake($nsModule)) { - $undeclared[$type][] = $module; - } elseif ((in_array($module, $declared) || in_array($nsModule, $declared)) && $this->_isFake($nsModule)) { - $this->_setDependencies($currentModule, $type, self::MAP_TYPE_REDUNDANT, $module); + + $module = $dependency['module']; + if (is_array($module)) { + $this->collectConditionalDependencies($module, $type, $currentModule, $declared, $undeclared); + } else { + $nsModule = str_replace('_', '\\', $module); + + if (!in_array($nsModule, $declared) && !$this->_isFake($nsModule)) { + $undeclared[$type][] = $module; + } elseif (in_array($nsModule, $declared) && $this->_isFake($nsModule)) { + $this->_setDependencies($currentModule, $type, self::MAP_TYPE_REDUNDANT, $module); + } + + $this->addDependency($currentModule, $type, self::MAP_TYPE_FOUND, $nsModule); } + } - $this->addDependency($currentModule, $type, self::MAP_TYPE_FOUND, $nsModule); + /** + * Collect non-strict dependencies when the module depends on one of modules + * + * @param array $conditionalDependencies + * @param string $type + * @param string $currentModule + * @param array $declared + * @param array $undeclared + */ + private function collectConditionalDependencies( + array $conditionalDependencies, + string $type, + string $currentModule, + array $declared, + array &$undeclared + ) { + array_walk( + $conditionalDependencies, + function (&$moduleName) { + $moduleName = str_replace('_', '\\', $moduleName); + } + ); + $declaredDependencies = array_intersect($conditionalDependencies, $declared); + + foreach ($declaredDependencies as $moduleName) { + if ($this->_isFake($moduleName)) { + $this->_setDependencies($currentModule, $type, self::MAP_TYPE_REDUNDANT, $moduleName); + } + + $this->addDependency($currentModule, $type, self::MAP_TYPE_FOUND, $moduleName); + } + + if (empty($declaredDependencies)) { + $undeclared[$type][] = implode(" || ", $conditionalDependencies); + } } /** @@ -718,10 +796,14 @@ private static function addDependencies( string $type, array $packageModuleMap ): void { - $packageNames = array_filter($packageNames, function ($packageName) use ($packageModuleMap) { - return isset($packageModuleMap[$packageName]) || - 0 === strpos($packageName, 'magento/') && 'magento/magento-composer-installer' != $packageName; - }); + $packageNames = array_filter( + $packageNames, + function ($packageName) use ($packageModuleMap) { + return isset($packageModuleMap[$packageName]) || + 0 === strpos($packageName, 'magento/') + && 'magento/magento-composer-installer' != $packageName; + } + ); foreach ($packageNames as $packageName) { self::addDependency( diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/whitelist/routes_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/whitelist/routes_ce.php new file mode 100644 index 0000000000000..9ebc951a3a3a1 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/whitelist/routes_ce.php @@ -0,0 +1,10 @@ + Date: Sun, 9 Jun 2019 21:26:30 -0500 Subject: [PATCH 3/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test --- .../Catalog/Block/Adminhtml/Product/Grid.php | 2 + .../Checkout/Controller/Onepage/SaveOrder.php | 6 +- .../Payflow/Service/Request/SecureToken.php | 2 +- .../Test/Unit/Block/Adminhtml/RssTest.php | 24 +++- .../TestFramework/Dependency/PhpRule.php | 3 + .../TestFramework/Dependency/PhpRuleTest.php | 129 +++++++++++++++--- 6 files changed, 144 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 6774d5df3cd91..4b537a78adc6a 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -8,6 +8,8 @@ use Magento\Store\Model\Store; /** + * Catalog product grid + * * @api * @since 100.0.2 */ diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index 27d272330a8d2..66b054136203a 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -6,10 +6,14 @@ namespace Magento\Checkout\Controller\Onepage; +use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\DataObject; use Magento\Framework\Exception\PaymentException; -class SaveOrder extends \Magento\Checkout\Controller\Onepage +/** + * One Page Checkout saveOrder action + */ +class SaveOrder extends \Magento\Checkout\Controller\Onepage implements HttpPostActionInterface { /** * Create order action diff --git a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php index 587372189f7ff..4eaf705abd2be 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php +++ b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php @@ -69,7 +69,7 @@ public function requestToken(Quote $quote) $request->setSecuretokenid($this->mathRandom->getUniqueHash()); $request->setReturnurl($this->url->getUrl('paypal/transparent/response')); $request->setErrorurl($this->url->getUrl('paypal/transparent/response')); - $request->setCancelurl(''); + $request->setCancelurl($this->url->getUrl('paypal/transparent/response')); $request->setDisablereceipt('TRUE'); $request->setSilenttran('TRUE'); diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php index 8455f1f7c68f7..dbd2bff41473b 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php @@ -8,6 +8,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * Test RSS adminhtml block + */ class RssTest extends \PHPUnit\Framework\TestCase { /** @@ -35,6 +38,9 @@ class RssTest extends \PHPUnit\Framework\TestCase */ protected $urlBuilder; + /** + * @inheritDoc + */ protected function setUp() { $this->storeManagerInterface = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); @@ -51,18 +57,22 @@ protected function setUp() ); } + /** + * @return void + */ public function testGetRssData() { + $rssUrl = ''; $rssData = [ 'title' => 'Pending product review(s)', 'description' => 'Pending product review(s)', - 'link' => 'http://rss.magento.com', + 'link' => $rssUrl, 'charset' => 'UTF-8', 'entries' => [ 'title' => 'Product: "Product Name" reviewed by: Product Nick', 'link' => 'http://product.magento.com', 'description' => [ - 'rss_url' => 'http://rss.magento.com', + 'rss_url' => $rssUrl, 'name' => 'Product Name', 'summary' => 'Product Title', 'review' => 'Product Detail', @@ -71,7 +81,6 @@ public function testGetRssData() ], ], ]; - $rssUrl = 'http://rss.magento.com'; $productModel = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Product::class, [ 'getStoreId', 'getId', @@ -118,16 +127,25 @@ public function testGetRssData() $this->assertContains($rssData['entries']['description']['store'], $data['entries'][0]['description']); } + /** + * @return void + */ public function testGetCacheLifetime() { $this->assertEquals(0, $this->block->getCacheLifetime()); } + /** + * @return void + */ public function testIsAllowed() { $this->assertEquals(true, $this->block->isAllowed()); } + /** + * @return void + */ public function testGetFeeds() { $this->assertEquals([], $this->block->getFeeds()); diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php index f4131c4c7d834..4958795412681 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php @@ -304,6 +304,9 @@ protected function _caseGetUrl(string $currentModule, string &$contents): array $item['action_name'] ?? UrlInterface::DEFAULT_ACTION_NAME ); if (!in_array($currentModule, $modules)) { + if (count($modules) === 1) { + $modules = reset($modules); + } $dependencies[] = [ 'module' => $modules, 'type' => RuleInterface::TYPE_HARD, diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php index 8fb883f79bfa7..a636aa81800d1 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php @@ -5,6 +5,13 @@ */ namespace Magento\TestFramework\Dependency; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\TestFramework\Exception\NoSuchActionException; + +/** + * Test for PhpRule dependency check + */ class PhpRuleTest extends \PHPUnit\Framework\TestCase { /** @@ -12,6 +19,15 @@ class PhpRuleTest extends \PHPUnit\Framework\TestCase */ protected $model; + /** + * @var ObjectManagerHelper + */ + private $objectManagerHelper; + + /** + * @inheritDoc + * @throws \Exception + */ protected function setUp() { $mapRoutes = ['someModule' => ['Magento\SomeModule'], 'anotherModule' => ['Magento\OneModule']]; @@ -20,9 +36,23 @@ protected function setUp() 'Magento\Module1\Plugin1' => 'Magento\Module1\Subject', 'Magento\Module1\Plugin2' => 'Magento\Module2\Subject', ]; - $this->model = new PhpRule($mapRoutes, $mapLayoutBlocks, $pluginMap); + $whitelist = []; + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->model = $this->objectManagerHelper->getObject( + PhpRule::class, + [ + 'mapRouters' => $mapRoutes, + 'mapLayoutBlocks' => $mapLayoutBlocks, + 'pluginMap' => $pluginMap, + 'whitelists' => $whitelist, + ] + ); } + /** + * @throws \Exception + */ public function testNonPhpGetDependencyInfo() { $content = 'any content'; @@ -34,6 +64,7 @@ public function testNonPhpGetDependencyInfo() * @param string $content * @param array $expected * @dataProvider getDependencyInfoDataProvider + * @throws \Exception */ public function testGetDependencyInfo($class, $content, array $expected) { @@ -96,22 +127,6 @@ public function getDependencyInfoDataProvider() ] ] ], - 'getUrl from same module' => [ - 'Magento\SomeModule\SomeClass', - '$this->getUrl("someModule")', - [] - ], - 'getUrl from another module' => [ - 'Magento\SomeModule\SomeClass', - '$this->getUrl("anotherModule")', - [ - [ - 'module' => 'Magento\OneModule', - 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, - 'source' => 'getUrl("anotherModule"', - ] - ] - ], 'getBlock from same module' => [ 'Magento\SomeModule\SomeClass', '$this->getLayout()->getBlock(\'block.name\');', [] @@ -173,11 +188,88 @@ public function getDependencyInfoDataProvider() ]; } + /** + * @param string $class + * @param string $content + * @param array $expected + * @throws \Exception + * @dataProvider getDependencyInfoDataCaseGetUrlDataProvider + */ + public function testGetDependencyInfoCaseGetUrl( + string $class, + string $content, + array $expected + ) { + $file = $this->makeMockFilepath($class); + $module = $this->getModuleFromClass($class); + + $this->assertEquals($expected, $this->model->getDependencyInfo($module, 'php', $file, $content)); + } + + /** + * @return array + */ + public function getDependencyInfoDataCaseGetUrlDataProvider() + { + return [ + 'getUrl from same module' => [ + 'Magento\Cms\SomeClass', + '$this->getUrl("cms/index/index")', + [] + ], + 'getUrl from another module' => [ + 'Magento\SomeModule\SomeClass', + '$this->getUrl("cms/index/index")', + [ + [ + 'module' => 'Magento\Cms', + 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, + 'source' => 'getUrl("cms/index/index"', + ] + ] + ], + ]; + } + + /** + * @param string $class + * @param string $content + * @param \Exception $expected + * @throws \Exception + * @dataProvider getDependencyInfoDataCaseGetUrlExceptionDataProvider + */ + public function testGetDependencyInfoCaseGetUrlException( + string $class, + string $content, + \Exception $expected + ) { + $file = $this->makeMockFilepath($class); + $module = $this->getModuleFromClass($class); + $this->expectExceptionObject($expected); + + $this->model->getDependencyInfo($module, 'php', $file, $content); + } + + /** + * @return array + */ + public function getDependencyInfoDataCaseGetUrlExceptionDataProvider() + { + return [ + 'getUrl from same module' => [ + 'Magento\SomeModule\SomeClass', + '$this->getUrl("someModule")', + new LocalizedException(__('Invalid URL path: %1', 'somemodule/index/index')), + ], + ]; + } + /** * @param string $module * @param string $content * @param array $expected * @dataProvider getDefaultModelDependencyDataProvider + * @throws \Exception */ public function testGetDefaultModelDependency($module, $content, array $expected) { @@ -192,6 +284,9 @@ public function testGetDefaultModelDependency($module, $content, array $expected $this->assertEquals($expected, $this->model->getDependencyInfo($module, 'template', 'any', $content)); } + /** + * @return array + */ public function getDefaultModelDependencyDataProvider() { return [ From b0366a249c7f5d71fe8cfb05ca8b36e96d52d170 Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Tue, 11 Jun 2019 15:05:43 -0500 Subject: [PATCH 4/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test -- fix merge conflict --- app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 4b537a78adc6a..7e43f2fc064ad 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -16,7 +16,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** - * @var \Magento\Framework\Module\Manager + * @var \Magento\Framework\Module\ModuleManagerInterface */ protected $moduleManager; @@ -59,7 +59,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended * @param \Magento\Catalog\Model\Product\Type $type * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status * @param \Magento\Catalog\Model\Product\Visibility $visibility - * @param \Magento\Framework\Module\Manager $moduleManager + * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -73,7 +73,7 @@ public function __construct( \Magento\Catalog\Model\Product\Type $type, \Magento\Catalog\Model\Product\Attribute\Source\Status $status, \Magento\Catalog\Model\Product\Visibility $visibility, - \Magento\Framework\Module\Manager $moduleManager, + \Magento\Framework\Module\ModuleManagerInterface $moduleManager, array $data = [] ) { $this->_websiteFactory = $websiteFactory; @@ -101,7 +101,7 @@ protected function _construct() } /** - * Get store + * Get store. * * @return Store * @throws \Magento\Framework\Exception\NoSuchEntityException From 54358cfb7c85ef189c521b0bde8aec1d27ab4e3d Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Tue, 11 Jun 2019 15:06:09 -0500 Subject: [PATCH 5/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test --- .../Review/Test/Unit/Block/Adminhtml/RssTest.php | 7 +++++-- .../testsuite/Magento/Test/Legacy/LayoutTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php index dbd2bff41473b..2ffd0ea118147 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Adminhtml/RssTest.php @@ -81,7 +81,9 @@ public function testGetRssData() ], ], ]; - $productModel = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Product::class, [ + $productModel = $this->createPartialMock( + \Magento\Catalog\Model\ResourceModel\Product::class, + [ 'getStoreId', 'getId', 'getReviewId', @@ -90,7 +92,8 @@ public function testGetRssData() 'getTitle', 'getNickname', 'getProductUrl' - ]); + ] + ); $storeModel = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerInterface->expects($this->once())->method('getStore')->will($this->returnValue($storeModel)); $storeModel->expects($this->once())->method('getName') diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php index 1ee599a04463d..4efad02468a39 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php @@ -11,6 +11,9 @@ use Magento\Framework\Component\ComponentRegistrar; +/** + * Layout test + */ class LayoutTest extends \PHPUnit\Framework\TestCase { /** @@ -85,6 +88,9 @@ class LayoutTest extends \PHPUnit\Framework\TestCase ], ]; + /** + * @throws \Exception + */ public function testLayoutFile() { $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); @@ -141,6 +147,11 @@ function ($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" . @@ -204,6 +215,9 @@ protected function _testObsoleteAttributes($layoutXml) } } + /** + * @throws \Exception + */ public function testActionNodeMethods() { $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); From 1d8362f2659687f1b2f798a0ed1ae90c0b5e88cc Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Tue, 18 Jun 2019 17:46:01 -0500 Subject: [PATCH 6/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test --- .../static/testsuite/Magento/Test/Integrity/DependencyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php index 1c50a3c43bf2a..16ba295588b58 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php @@ -480,7 +480,7 @@ function (&$moduleName) { $moduleName = str_replace('_', '\\', $moduleName); } ); - $declaredDependencies = array_intersect($conditionalDependencies, $declared); + $declaredDependencies = array_intersect($conditionalDependencies, $declared); foreach ($declaredDependencies as $moduleName) { if ($this->_isFake($moduleName)) { From 5abbe7e260192f67789c913eccd4a91662bd3296 Mon Sep 17 00:00:00 2001 From: Max Lesechko Date: Thu, 27 Jun 2019 11:54:17 -0500 Subject: [PATCH 7/7] MC-5806: Detection of URL dependencies does not work for the Dependency static test -- fix merge conflict --- .../static/testsuite/Magento/Test/Legacy/LayoutTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php index 4efad02468a39..dd2229968375e 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php @@ -3,16 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); -/** - * Coverage of obsolete nodes in layout - */ namespace Magento\Test\Legacy; use Magento\Framework\Component\ComponentRegistrar; /** - * Layout test + * Coverage of obsolete nodes in layout */ class LayoutTest extends \PHPUnit\Framework\TestCase { @@ -370,8 +368,6 @@ public function getAllowedActionNodeMethods() 'unsetChildren', 'updateButton', 'setIsProductListingContext', - 'checkCompanyStatus', // MAGETWO-88965 - 'setRendererType', // MAGETWO-88965 ]; } }