|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use TwinDigital\WPTools\PluginTools; |
|
4
|
|
|
|
|
5
|
|
|
class PluginToolsTest extends WP_UnitTestCase { |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Tests if the plugin_list is loaded. |
|
9
|
|
|
* |
|
10
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::loadPluginList() |
|
11
|
|
|
* @return void |
|
12
|
|
|
*/ |
|
13
|
|
|
public function testLoadPluginList() { |
|
14
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Tests if the plugin_list is loaded. |
|
19
|
|
|
* |
|
20
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::loadPluginList() |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function testLoadPluginListForced() { |
|
24
|
|
|
PluginTools::loadPluginList(true); |
|
25
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Tests if the plugin_list is loaded. |
|
30
|
|
|
* |
|
31
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::refreshLoadedPlugins() |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testRefreshLoadedPlugins() { |
|
35
|
|
|
PluginTools::$loadedPlugins = null; |
|
36
|
|
|
PluginTools::refreshLoadedPlugins(); |
|
37
|
|
|
$this->assertNotCount(0, PluginTools::$loadedPlugins, 'Pluginlist is empty, probably failed loading the list of plugins.'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Tests if getting a plugin by name is working as it should. |
|
42
|
|
|
* |
|
43
|
|
|
* @covers \TwinDigital\WPTools\PluginTools::getPluginByTitle() |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testGetPluginByTitle() { |
|
47
|
|
|
PluginTools::refreshLoadedPlugins(); |
|
48
|
|
|
$this->assertEmpty(PluginTools::getPluginByTitle('Non-existing-plugin'), 'Found a plugin that is non-existing? Oops'); |
|
49
|
|
|
$list_of_plugins_to_try = [ |
|
50
|
|
|
'Akismet Anti-Spam', |
|
51
|
|
|
'Hello Dolly', |
|
52
|
|
|
]; |
|
53
|
|
|
$plugin_details = null; |
|
54
|
|
|
foreach ($list_of_plugins_to_try as $plugin) { |
|
55
|
|
|
$plugin_details = PluginTools::getPluginByTitle($plugin); |
|
56
|
|
|
if ($plugin_details !== false) { |
|
57
|
|
|
break; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
$this->assertNotEmpty($plugin_details, 'Current plugin is not active?'); |
|
61
|
|
|
|
|
62
|
|
|
// Should not fail |
|
63
|
|
|
$list_of_plugins_to_try = [ |
|
64
|
|
|
'Akismet Anti-Spam', |
|
65
|
|
|
'Hello Dolly', |
|
66
|
|
|
]; |
|
67
|
|
|
$plugin_details = null; |
|
68
|
|
|
$installed_plugin = null; |
|
69
|
|
|
foreach ($list_of_plugins_to_try as $plugin) { |
|
70
|
|
|
$plugin_details = PluginTools::getPluginByTitle(strtolower($plugin), false); |
|
71
|
|
|
if ($plugin_details !== false) { |
|
72
|
|
|
$installed_plugin = $plugin; |
|
73
|
|
|
break; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
$this->assertNotEmpty($plugin_details, 'Current plugin is not active?'); |
|
77
|
|
|
|
|
78
|
|
|
// This should fail |
|
79
|
|
|
$plugin_details = null; |
|
|
|
|
|
|
80
|
|
|
$plugin_details = PluginTools::getPluginByTitle(strtolower($installed_plugin), false); |
|
81
|
|
|
$this->assertEmpty($plugin_details, 'Current plugin is not active?'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
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