Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
ConfigTest Class Reference
Inheritance diagram for ConfigTest:

Public Member Functions

 testPaymentMethods ()
 
 paymentMethodsDataProvider ()
 

Protected Member Functions

 _getConfigFilesPerModule ()
 

Detailed Description

Definition at line 10 of file ConfigTest.php.

Member Function Documentation

◆ _getConfigFilesPerModule()

_getConfigFilesPerModule ( )
protected

Get list of configuration files associated with modules

Returns
array

Definition at line 52 of file ConfigTest.php.

53  {
54  $data = [];
55  $componentRegistrar = new \Magento\Framework\Component\ComponentRegistrar();
56  $modulesPaths = $componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE);
57 
58  foreach ($modulesPaths as $moduleName => $path) {
59  if (file_exists($configFile = $path . '/etc/config.xml')) {
60  $data[$configFile] = $moduleName;
61  }
62  }
63  return $data;
64  }
$componentRegistrar
Definition: bootstrap.php:23

◆ paymentMethodsDataProvider()

paymentMethodsDataProvider ( )

Definition at line 38 of file ConfigTest.php.

39  {
40  $data = [];
41  foreach ($this->_getConfigFilesPerModule() as $configFile => $moduleName) {
42  $data[] = [$configFile, $moduleName];
43  }
44  return $data;
45  }

◆ testPaymentMethods()

testPaymentMethods ( )

Verify whether all payment methods are declared in appropriate modules

Definition at line 12 of file ConfigTest.php.

13  {
14  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
15  $invoker(
19  function ($configFile, $moduleName) {
20  $config = simplexml_load_file($configFile);
21  $nodes = $config->xpath('/config/default/payment/*/model') ?: [];
22  $formalModuleName = str_replace('_', '\\', $moduleName);
23  foreach ($nodes as $node) {
24  if (!Classes::isVirtual((string)$node)) {
25  $this->assertStringStartsWith(
26  $formalModuleName . '\Model\\',
27  (string)$node,
28  "'{$node}' payment method is declared in '{$configFile}' module, " .
29  "but doesn't belong to '{$moduleName}' module"
30  );
31  }
32  }
33  },
35  );
36  }
$config
Definition: fraud_order.php:17

The documentation for this class was generated from the following file: