diff --git a/tests/ServicesTest/PluginManagerTest.php b/tests/ServicesTest/PluginManagerTest.php index 0c62ec34..3d6e981b 100644 --- a/tests/ServicesTest/PluginManagerTest.php +++ b/tests/ServicesTest/PluginManagerTest.php @@ -23,7 +23,7 @@ class PluginManagerTest extends TestCase public function testNotLoadDisabled() { $dir = config('plugins.directory'); - config(['plugins.directory' => storage_path('mocks')]); + config(['plugins.directory' => base_path('tests/__mocks__')]); app()->forgetInstance(PluginManager::class); resolve(PluginManager::class)->boot(); @@ -207,7 +207,26 @@ class PluginManagerTest extends TestCase resolve(PluginManager::class)->boot(); } - public function testLoadViewsAndTranslations() + public function testLoadViews() + { + $dir = config('plugins.directory'); + config(['plugins.directory' => base_path('tests/__mocks__')]); + $this->mock(Option::class, function ($mock) { + $mock->shouldReceive('get') + ->with('plugins_enabled', '[]') + ->andReturn(json_encode([ + ['name' => 'fake-with-views', 'version' => '0.0.0'], + ])); + }); + + app()->forgetInstance(PluginManager::class); + resolve(PluginManager::class)->boot(); + $this->assertTrue(view()->exists('FakeWithViews::example')); + + config(['plugins.directory' => $dir]); + } + + public function testLoadTranslations() { $this->mock(Option::class, function ($mock) { $mock->shouldReceive('get') @@ -257,15 +276,6 @@ class PluginManagerTest extends TestCase '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\Translations\Loader::class, function ($mock) { $mock->shouldReceive('addNamespace') ->withArgs(['Mayaka', '/mayaka/lang']) @@ -432,7 +442,7 @@ class PluginManagerTest extends TestCase public function testRegisterAutoload() { $dir = config('plugins.directory'); - config(['plugins.directory' => storage_path('mocks')]); + config(['plugins.directory' => base_path('tests/__mocks__')]); $this->mock(Option::class, function ($mock) { $mock->shouldReceive('get') ->with('plugins_enabled', '[]') @@ -452,7 +462,7 @@ class PluginManagerTest extends TestCase Event::fake(); $dir = config('plugins.directory'); - config(['plugins.directory' => storage_path('mocks')]); + config(['plugins.directory' => base_path('tests/__mocks__')]); $this->mock(Option::class, function ($mock) { $mock->shouldReceive('get') ->with('plugins_enabled', '[]') diff --git a/storage/mocks/fake-plugin/package.json b/tests/__mocks__/fake-plugin/package.json similarity index 100% rename from storage/mocks/fake-plugin/package.json rename to tests/__mocks__/fake-plugin/package.json diff --git a/storage/mocks/fake-plugin/src/FakeServiceProvider.php b/tests/__mocks__/fake-plugin/src/FakeServiceProvider.php similarity index 100% rename from storage/mocks/fake-plugin/src/FakeServiceProvider.php rename to tests/__mocks__/fake-plugin/src/FakeServiceProvider.php diff --git a/tests/__mocks__/fake-with-views/package.json b/tests/__mocks__/fake-with-views/package.json new file mode 100644 index 00000000..51c14c76 --- /dev/null +++ b/tests/__mocks__/fake-with-views/package.json @@ -0,0 +1,5 @@ +{ + "name": "fake-with-views", + "version": "0.0.0", + "namespace": "FakeWithViews" +} diff --git a/tests/__mocks__/fake-with-views/views/example.blade.php b/tests/__mocks__/fake-with-views/views/example.blade.php new file mode 100644 index 00000000..da58d84a --- /dev/null +++ b/tests/__mocks__/fake-with-views/views/example.blade.php @@ -0,0 +1 @@ +Page Content.