![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/static/testsuite/Magento/Test/Integrity/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Test\Integrity; use Magento\Framework\App\Utility\Classes; class ConfigTest extends \PHPUnit\Framework\TestCase { public function testPaymentMethods() { $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); $invoker( /** * Verify whether all payment methods are declared in appropriate modules */ function ($configFile, $moduleName) { $config = simplexml_load_file($configFile); $nodes = $config->xpath('/config/default/payment/*/model') ?: []; $formalModuleName = str_replace('_', '\\', $moduleName); foreach ($nodes as $node) { if (!Classes::isVirtual((string)$node)) { $this->assertStringStartsWith( $formalModuleName . '\Model\\', (string)$node, "'{$node}' payment method is declared in '{$configFile}' module, " . "but doesn't belong to '{$moduleName}' module" ); } } }, $this->paymentMethodsDataProvider() ); } public function paymentMethodsDataProvider() { $data = []; foreach ($this->_getConfigFilesPerModule() as $configFile => $moduleName) { $data[] = [$configFile, $moduleName]; } return $data; } /** * Get list of configuration files associated with modules * * @return array */ protected function _getConfigFilesPerModule() { $data = []; $componentRegistrar = new \Magento\Framework\Component\ComponentRegistrar(); $modulesPaths = $componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE); foreach ($modulesPaths as $moduleName => $path) { if (file_exists($configFile = $path . '/etc/config.xml')) { $data[$configFile] = $moduleName; } } return $data; } }