diff --git a/app/Services/Hook.php b/app/Services/Hook.php index 88081acc..e8dc1946 100644 --- a/app/Services/Hook.php +++ b/app/Services/Hook.php @@ -48,6 +48,8 @@ class Hook * Add a route. A router instance will be passed to the given callback. * * @param Closure $callback + * + * TODO: Needs to be tested. */ public static function addRoute(Closure $callback) { diff --git a/tests/ServicesTest/HookTest.php b/tests/ServicesTest/HookTest.php new file mode 100644 index 00000000..e0f14735 --- /dev/null +++ b/tests/ServicesTest/HookTest.php @@ -0,0 +1,55 @@ + 'Go to closet', + 'link' => '/user/closet', + 'icon' => 'fa-book' + ]); + $this->actAs('normal') + ->visit('/user') + ->see('Go to closet') + ->see('/user/closet') + ->see('fa-book') + ->click('Go to closet') + ->seePageIs('/user/closet'); + } + + public function testRegisterPluginTransScripts() + { + Hook::registerPluginTransScripts('example-plugin'); + $this->get('/') + ->see('example-plugin/lang/en/locale.js'); + } + + public function testAddStyleFileToPage() + { + Hook::addStyleFileToPage('/style/all'); + $this->visit('/') + ->see(''); + + Hook::addStyleFileToPage('/style/pattern', ['skinlib']); + $this->visit('/') + ->dontSee(''); + $this->visit('/skinlib') + ->see(''); + } + + public function testAddScriptFileToPage() + { + Hook::addScriptFileToPage('/script/all'); + $this->visit('/') + ->see(''); + + Hook::addScriptFileToPage('/script/pattern', ['skinlib']); + $this->visit('/') + ->dontSee(''); + $this->visit('/skinlib') + ->see(''); + } +}