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

Public Member Functions

 testConstructorException ($configFile, $baseDir)
 
 constructorExceptionDataProvider ()
 
 testFindWords ($configFiles, $file, $expected)
 
 findWordsDataProvider ()
 

Detailed Description

Definition at line 10 of file WordsFinderTest.php.

Member Function Documentation

◆ constructorExceptionDataProvider()

constructorExceptionDataProvider ( )

Definition at line 23 of file WordsFinderTest.php.

24  {
25  $fixturePath = __DIR__ . '/_files/';
26  return [
27  'non-existing config file' => [$fixturePath . 'non-existing.xml', $fixturePath],
28  'non-existing base dir' => [$fixturePath . 'config.xml', $fixturePath . 'non-existing-dir'],
29  'broken config' => [$fixturePath . 'broken_config.xml', $fixturePath],
30  'empty words config' => [$fixturePath . 'empty_words_config.xml', $fixturePath],
31  'empty whitelisted path' => [$fixturePath . 'empty_whitelisted_path.xml', $fixturePath]
32  ];
33  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ findWordsDataProvider()

findWordsDataProvider ( )
Returns
array

Definition at line 55 of file WordsFinderTest.php.

56  {
57  $mainConfig = __DIR__ . '/_files/config.xml';
58  $additionalConfig = __DIR__ . '/_files/config_additional.xml';
59  $basePath = __DIR__ . '/_files/words_finder/';
60  return [
61  'usual file' => [$mainConfig, $basePath . 'buffy.php', ['demon', 'vampire']],
62  'whitelisted file' => [$mainConfig, $basePath . 'twilight/eclipse.php', []],
63  'partially whitelisted file' => [$mainConfig, $basePath . 'twilight/newmoon.php', ['demon']],
64  'filename with bad word' => [
65  $mainConfig,
66  $basePath . 'interview_with_the_vampire.php',
67  ['vampire'],
68  ],
69  'binary file, having name with bad word' => [
70  $mainConfig,
71  $basePath . 'interview_with_the_vampire.zip',
72  ['vampire'],
73  ],
74  'words in multiple configs' => [
75  [$mainConfig, $additionalConfig],
76  $basePath . 'buffy.php',
77  ['demon', 'vampire', 'darkness'],
78  ],
79  'whitelisted paths in multiple configs' => [
80  [$mainConfig, $additionalConfig],
81  $basePath . 'twilight/newmoon.php',
82  ['demon'],
83  ],
84  'config must be whitelisted automatically' => [
85  $basePath . 'self_tested_config.xml',
86  $basePath . 'self_tested_config.xml',
87  [],
88  ]
89  ];
90  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testConstructorException()

testConstructorException (   $configFile,
  $baseDir 
)
Parameters
string$configFile
string$baseDir@expectedException \Magento\TestFramework\Inspection\Exception @dataProvider constructorExceptionDataProvider

Definition at line 18 of file WordsFinderTest.php.

19  {
20  new \Magento\TestFramework\Inspection\WordsFinder($configFile, $baseDir, new ComponentRegistrar());
21  }
$baseDir
Definition: autoload.php:9

◆ testFindWords()

testFindWords (   $configFiles,
  $file,
  $expected 
)
Parameters
string | array$configFiles
string$file
array$expected@dataProvider findWordsDataProvider

Definition at line 41 of file WordsFinderTest.php.

42  {
43  $wordsFinder = new \Magento\TestFramework\Inspection\WordsFinder(
44  $configFiles,
45  __DIR__ . '/_files/words_finder',
46  new ComponentRegistrar()
47  );
48  $actual = $wordsFinder->findWords($file);
49  $this->assertEquals($expected, $actual);
50  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

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