Passed
Push — master ( 8ec7ae...f60e59 )
by Lucien
01:27
created

PluginToolsTest::testRefreshLoadedPlugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use TwinDigital\WPTools\PluginTools;
5
6
class PluginToolsTest extends WP_UnitTestCase {
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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