- $data = array(0 => 'woot');
- $pluginManager->executeHooks('random', $data, array('loggedin' => true));
- $this->assertEquals('loggedin', $data[1]);
+ 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->assertSame(
+ 'test [plugin incompatibility]: Class \'Unknown\' not found',
+ $this->pluginManager->getErrors()[0]
+ );