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

Public Member Functions

 testCopyright ()
 
 copyrightDataProvider ()
 

Protected Member Functions

 getFilesData ($filePattern)
 

Detailed Description

Definition at line 12 of file CopyrightTest.php.

Member Function Documentation

◆ copyrightDataProvider()

copyrightDataProvider ( )

Definition at line 28 of file CopyrightTest.php.

29  {
30  $blackList = $this->getFilesData('blacklist*.php');
31 
32  $changedFiles = [];
33  foreach (glob(__DIR__ . '/../_files/changed_files*') as $listFile) {
34  $changedFiles = array_merge($changedFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
35  }
36  array_walk(
38  function (&$file) {
39  $file = [BP . '/' . $file];
40  }
41  );
42  $changedFiles = array_filter(
44  function ($path) use ($blackList) {
45  if (!file_exists($path[0]) || !is_readable($path[0])) {
46  return false;
47  }
48  $path[0] = realpath($path[0]);
49  foreach ($blackList as $item) {
50  if (preg_match($item, $path[0])) {
51  return false;
52  }
53  }
54  return true;
55  }
56  );
57  return $changedFiles;
58  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
const BP
Definition: autoload.php:14

◆ getFilesData()

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

Definition at line 64 of file CopyrightTest.php.

65  {
66  $result = [];
67  foreach (glob(__DIR__ . '/_files/copyright/' . $filePattern) as $file) {
68  $fileData = include $file;
69  $result = array_merge($result, $fileData);
70  }
71  return $result;
72  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testCopyright()

testCopyright ( )

Definition at line 14 of file CopyrightTest.php.

15  {
16  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
17  $invoker(
18  function ($filename) {
19  $fileText = file_get_contents($filename);
20  if (strpos($fileText, 'Copyright © Magento, Inc. All rights reserved.') === false) {
21  $this->fail('Copyright is missing or has wrong format ' . $filename);
22  }
23  },
24  $this->copyrightDataProvider()
25  );
26  }

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