diff --git a/app/Services/PluginManager.php b/app/Services/PluginManager.php index f3426d54..836af89f 100644 --- a/app/Services/PluginManager.php +++ b/app/Services/PluginManager.php @@ -136,6 +136,10 @@ class PluginManager return; } + $this->all()->each(function ($plugin) { + $this->loadViewsAndTranslations($plugin); + }); + $enabled = $this->getEnabledPlugins(); $enabled->each(function ($plugin) { $this->registerPlugin($plugin); @@ -155,7 +159,6 @@ class PluginManager { $this->registerAutoload($plugin); $this->loadVendor($plugin); - $this->loadViewsAndTranslations($plugin); } /** diff --git a/tests/ServicesTest/PluginManagerTest.php b/tests/ServicesTest/PluginManagerTest.php index 97f32896..3e93c37d 100644 --- a/tests/ServicesTest/PluginManagerTest.php +++ b/tests/ServicesTest/PluginManagerTest.php @@ -212,7 +212,7 @@ class PluginManagerTest extends TestCase $mock->shouldReceive('directories') ->with(base_path('plugins')) ->once() - ->andReturn(collect(['/mayaka'])); + ->andReturn(collect(['/mayaka', '/chitanda'])); $mock->shouldReceive('exists') ->with('/mayaka'.DIRECTORY_SEPARATOR.'package.json') @@ -236,16 +236,38 @@ class PluginManagerTest extends TestCase ->with('/mayaka/bootstrap.php') ->once() ->andReturn(false); + + $mock->shouldReceive('exists') + ->with('/chitanda'.DIRECTORY_SEPARATOR.'package.json') + ->once() + ->andReturn(true); + + $mock->shouldReceive('get') + ->with('/chitanda'.DIRECTORY_SEPARATOR.'package.json') + ->once() + ->andReturn(json_encode([ + 'name' => 'chitanda', + 'version' => '0.0.0', + 'namespace' => 'Chitanda', + ])); }); $this->mock('view', function ($mock) { $mock->shouldReceive('addNamespace') ->withArgs(['Mayaka', '/mayaka/views']) ->once(); + + $mock->shouldReceive('addNamespace') + ->withArgs(['Chitanda', '/chitanda/views']) + ->once(); }); $this->instance('translation.loader', \Mockery::mock(\App\Services\TranslationLoader::class, function ($mock) { $mock->shouldReceive('addNamespace') ->withArgs(['Mayaka', '/mayaka/lang']) ->once(); + + $mock->shouldReceive('addNamespace') + ->withArgs(['Chitanda', '/chitanda/lang']) + ->once(); })); app()->forgetInstance(PluginManager::class);