From e6e989281c53f0e2bfc733d572c9379a42433f4b Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 19 Aug 2018 17:54:00 +0800 Subject: [PATCH] Fix tests --- tests/PluginControllerTest.php | 4 ++-- tests/ServicesTest/HookTest.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/PluginControllerTest.php b/tests/PluginControllerTest.php index f7038930..b83e845f 100644 --- a/tests/PluginControllerTest.php +++ b/tests/PluginControllerTest.php @@ -44,8 +44,8 @@ class PluginControllerTest extends TestCase ->assertNotFound(); // Plugin has config view - plugin('example-plugin')->setEnabled(true); - $this->get('/admin/plugins/config/example-plugin') + plugin('fake-plugin-with-config-view')->setEnabled(true); + $this->get('/admin/plugins/config/fake-plugin-with-config-view') ->assertSuccessful(); } diff --git a/tests/ServicesTest/HookTest.php b/tests/ServicesTest/HookTest.php index 3746b2e8..936e1d53 100644 --- a/tests/ServicesTest/HookTest.php +++ b/tests/ServicesTest/HookTest.php @@ -3,9 +3,13 @@ namespace Tests; use App\Services\Hook; +use Illuminate\Support\Facades\File; +use Tests\Concerns\GeneratesFakePlugins; class HookTest extends TestCase { + use GeneratesFakePlugins; + public function testAddMenuItem() { Hook::addMenuItem('user', 0, [ @@ -22,9 +26,15 @@ class HookTest extends TestCase public function testRegisterPluginTransScripts() { - Hook::registerPluginTransScripts('example-plugin'); + $this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']); + @mkdir($path = base_path('plugins/fake-plugin-with-i18n/lang/en'), 0755, true); + file_put_contents("$path/locale.js", ''); + + Hook::registerPluginTransScripts('fake-plugin-with-i18n'); $this->get('/') - ->assertSee('example-plugin/lang/en/locale.js'); + ->assertSee('fake-plugin-with-i18n/lang/en/locale.js'); + + File::deleteDirectory(base_path('plugins/fake-plugin-with-i18n')); } public function testAddStyleFileToPage()