From ca4d1b5d04d8dab9ef1c0a7fcb28dcdd56caa5d9 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 23 Aug 2019 14:20:04 +0800 Subject: [PATCH] Inject current plugin at bootstrapper --- app/Services/PluginManager.php | 2 +- tests/ServicesTest/PluginManagerTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/PluginManager.php b/app/Services/PluginManager.php index 0f0a59b2..f3426d54 100644 --- a/app/Services/PluginManager.php +++ b/app/Services/PluginManager.php @@ -230,7 +230,7 @@ class PluginManager { $path = $plugin->getPath().'/bootstrap.php'; if ($this->filesystem->exists($path)) { - $this->app->call($this->filesystem->getRequire($path)); + $this->app->call($this->filesystem->getRequire($path), ['plugin' => $plugin]); } } diff --git a/tests/ServicesTest/PluginManagerTest.php b/tests/ServicesTest/PluginManagerTest.php index 88e8edda..97f32896 100644 --- a/tests/ServicesTest/PluginManagerTest.php +++ b/tests/ServicesTest/PluginManagerTest.php @@ -291,8 +291,9 @@ class PluginManagerTest extends TestCase $mock->shouldReceive('getRequire') ->with('/mayaka/bootstrap.php') ->once() - ->andReturn(function (\Illuminate\Contracts\Events\Dispatcher $events) { + ->andReturn(function (\Illuminate\Contracts\Events\Dispatcher $events, Plugin $plugin) { $this->assertTrue(method_exists($events, 'listen')); + $this->assertEquals('mayaka', $plugin->name); }); });