1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
4
|
|
|
use TwinDigital\WPTools\PluginTools; |
5
|
|
|
|
6
|
|
|
class PluginToolsTest extends WP_UnitTestCase { |
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Tests if the plugin_list is loaded. |
10
|
|
|
* |
11
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::loadPluginList() |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function testLoadPluginList() { |
15
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Tests if the plugin_list is loaded. |
20
|
|
|
* |
21
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::loadPluginList() |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function testLoadPluginListForced() { |
25
|
|
|
PluginTools::loadPluginList(true); |
26
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests if the plugin_list is loaded. |
31
|
|
|
* |
32
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::refreshLoadedPlugins() |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function testRefreshLoadedPlugins() { |
36
|
|
|
PluginTools::$loadedPlugins = null; |
37
|
|
|
PluginTools::refreshLoadedPlugins(); |
38
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Tests if the plugin_list is loaded. |
43
|
|
|
* |
44
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::getPluginByTitle() |
45
|
|
|
* @return void |
46
|
|
|
*/ |
47
|
|
|
public function testGetPluginByTitle() { |
48
|
|
|
PluginTools::refreshLoadedPlugins(); |
49
|
|
|
echo 'Plugin-list:' . PHP_EOL; |
50
|
|
|
print_r(PluginTools::$loadedPlugins); |
51
|
|
|
echo 'End of lugin-list:' . PHP_EOL; |
52
|
|
|
$this->assertEmpty(PluginTools::getPluginByTitle('Non-existing-plugin'), 'Found a plugin that is non-existing? Oops'); |
53
|
|
|
$list_of_plugins_to_try = [ |
54
|
|
|
'Akismet Anti-Spam', |
55
|
|
|
'Hello Dolly', |
56
|
|
|
]; |
57
|
|
|
$plugin_details = null; |
58
|
|
|
foreach ($list_of_plugins_to_try as $plugin) { |
59
|
|
|
$plugin_details = PluginTools::getPluginByTitle('Akismet Anti-Spam'); |
60
|
|
|
if ($plugin_details !== false) { |
61
|
|
|
break; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
$this->assertNotEmpty($plugin_details, 'Current plugin is not active?'); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths