+
+ static::assertCount(2, $data);
+ static::assertEquals('loggedin', $data[1]);
+
+ $data = [0 => 'woot'];
+ $this->pluginManager->executeHooks('random', $data, array('loggedin' => null));
+
+ static::assertCount(3, $data);
+ static::assertEquals('loggedin', $data[1]);
+ static::assertArrayHasKey(2, $data);
+ static::assertNull($data[2]);
+ }
+
+ /**
+ * Test plugin loading and hook execution with an error: raise an incompatibility error.
+ */
+ public function testPluginWithPhpError(): void
+ {
+ PluginManager::$PLUGINS_PATH = self::$pluginPath;
+ $this->pluginManager->load(array(self::$pluginName));
+
+ $this->assertTrue(function_exists('hook_test_error'));
+
+ $data = [];
+ $this->pluginManager->executeHooks('error', $data);
+
+ $this->assertRegExp(
+ '/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/',
+ $this->pluginManager->getErrors()[0]
+ );