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

Public Member Functions

 testObsoleteResponseMethods ()
 
 modulesFilesDataProvider ()
 

Protected Member Functions

 setUp ()
 
 getBlackList ()
 
 getFilesData ($filePattern)
 

Protected Attributes

 $obsoleteMethods = []
 
 $filesBlackList = []
 
 $appPath
 

Detailed Description

Temporary test that will be removed in scope of MAGETWO-28356. Test verifies obsolete usages in modules that were refactored to work with ResultInterface.

Definition at line 14 of file ObsoleteResponseTest.php.

Member Function Documentation

◆ getBlackList()

getBlackList ( )
protected
Returns
array

Definition at line 86 of file ObsoleteResponseTest.php.

87  {
88  $blackListFiles = [];
89  $componentRegistrar = new ComponentRegistrar();
90  foreach ($this->getFilesData('blacklist/files_list*') as $fileInfo) {
91  $blackListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0])
92  . DIRECTORY_SEPARATOR . $fileInfo[1];
93  }
94  return $blackListFiles;
95  }
$componentRegistrar
Definition: bootstrap.php:23

◆ getFilesData()

getFilesData (   $filePattern)
protected
Parameters
string$filePattern
Returns
array

Definition at line 101 of file ObsoleteResponseTest.php.

102  {
103  $result = [];
104  foreach (glob(__DIR__ . '/_files/response/' . $filePattern) as $file) {
105  $fileData = include $file;
106  $result = array_merge($result, $fileData);
107  }
108  return $result;
109  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ modulesFilesDataProvider()

modulesFilesDataProvider ( )

Return refactored files

Returns
array

Definition at line 64 of file ObsoleteResponseTest.php.

65  {
66  $filesList = [];
67  $componentRegistrar = new ComponentRegistrar();
68  foreach ($this->getFilesData('whitelist/refactored_modules*') as $refactoredModule) {
69  if ($componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)) {
71  [$componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)],
72  '*.php'
73  );
74  $filesList = array_merge($filesList, $files);
75  }
76  }
77 
78  $result = array_map('realpath', $filesList);
79  $result = array_diff($result, $this->filesBlackList);
80  return \Magento\Framework\App\Utility\Files::composeDataSets($result);
81  }
$componentRegistrar
Definition: bootstrap.php:23
foreach($appDirs as $dir) $files

◆ setUp()

setUp ( )
protected

Definition at line 31 of file ObsoleteResponseTest.php.

32  {
33  $this->obsoleteMethods = include __DIR__ . '/_files/response/obsolete_response_methods.php';
34  $this->filesBlackList = $this->getBlackList();
35  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testObsoleteResponseMethods()

testObsoleteResponseMethods ( )

Test verify that obsolete methods do not appear in refactored folders

Definition at line 40 of file ObsoleteResponseTest.php.

41  {
42  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
43  $invoker(
44  function ($file) {
45  $content = file_get_contents($file);
46  foreach ($this->obsoleteMethods as $method) {
47  $quotedMethod = preg_quote($method, '/');
48  $this->assertSame(
49  0,
50  preg_match('/(?<=[a-z\\d_:]|->|function\\s)' . $quotedMethod . '\\s*\\(/iS', $content),
51  "File: $file\nContains obsolete method: $method . "
52  );
53  }
54  },
56  );
57  }
$method
Definition: info.phtml:13

Field Documentation

◆ $appPath

$appPath
protected

Definition at line 29 of file ObsoleteResponseTest.php.

◆ $filesBlackList

$filesBlackList = []
protected

Definition at line 24 of file ObsoleteResponseTest.php.

◆ $obsoleteMethods

$obsoleteMethods = []
protected

Definition at line 19 of file ObsoleteResponseTest.php.


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