aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r--tests/PluginManagerTest.php44
1 files changed, 29 insertions, 15 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index a5d5dbe9..3018999c 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -41,17 +41,31 @@ class PluginManagerTest extends \PHPUnit\Framework\TestCase
41 41
42 $this->assertTrue(function_exists('hook_test_random')); 42 $this->assertTrue(function_exists('hook_test_random'));
43 43
44 $data = array(0 => 'woot'); 44 $data = [0 => 'woot'];
45 $this->pluginManager->executeHooks('random', $data); 45 $this->pluginManager->executeHooks('random', $data);
46 $this->assertEquals('woot', $data[1]);
47 46
48 $data = array(0 => 'woot'); 47 static::assertCount(2, $data);
48 static::assertSame('woot', $data[1]);
49
50 $data = [0 => 'woot'];
49 $this->pluginManager->executeHooks('random', $data, array('target' => 'test')); 51 $this->pluginManager->executeHooks('random', $data, array('target' => 'test'));
50 $this->assertEquals('page test', $data[1]);
51 52
52 $data = array(0 => 'woot'); 53 static::assertCount(2, $data);
54 static::assertSame('page test', $data[1]);
55
56 $data = [0 => 'woot'];
53 $this->pluginManager->executeHooks('random', $data, array('loggedin' => true)); 57 $this->pluginManager->executeHooks('random', $data, array('loggedin' => true));
54 $this->assertEquals('loggedin', $data[1]); 58
59 static::assertCount(2, $data);
60 static::assertEquals('loggedin', $data[1]);
61
62 $data = [0 => 'woot'];
63 $this->pluginManager->executeHooks('random', $data, array('loggedin' => null));
64
65 static::assertCount(3, $data);
66 static::assertEquals('loggedin', $data[1]);
67 static::assertArrayHasKey(2, $data);
68 static::assertNull($data[2]);
55 } 69 }
56 70
57 /** 71 /**
@@ -78,8 +92,8 @@ class PluginManagerTest extends \PHPUnit\Framework\TestCase
78 */ 92 */
79 public function testPluginNotFound(): void 93 public function testPluginNotFound(): void
80 { 94 {
81 $this->pluginManager->load(array()); 95 $this->pluginManager->load([]);
82 $this->pluginManager->load(array('nope', 'renope')); 96 $this->pluginManager->load(['nope', 'renope']);
83 $this->addToAssertionCount(1); 97 $this->addToAssertionCount(1);
84 } 98 }
85 99
@@ -89,18 +103,18 @@ class PluginManagerTest extends \PHPUnit\Framework\TestCase
89 public function testGetPluginsMeta(): void 103 public function testGetPluginsMeta(): void
90 { 104 {
91 PluginManager::$PLUGINS_PATH = self::$pluginPath; 105 PluginManager::$PLUGINS_PATH = self::$pluginPath;
92 $this->pluginManager->load(array(self::$pluginName)); 106 $this->pluginManager->load([self::$pluginName]);
93 107
94 $expectedParameters = array( 108 $expectedParameters = [
95 'pop' => array( 109 'pop' => [
96 'value' => '', 110 'value' => '',
97 'desc' => 'pop description', 111 'desc' => 'pop description',
98 ), 112 ],
99 'hip' => array( 113 'hip' => [
100 'value' => '', 114 'value' => '',
101 'desc' => '', 115 'desc' => '',
102 ), 116 ],
103 ); 117 ];
104 $meta = $this->pluginManager->getPluginsMeta(); 118 $meta = $this->pluginManager->getPluginsMeta();
105 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); 119 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']);
106 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); 120 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']);