From 293668960afe9b0bd985a6573db768789c3e5c59 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 5 Apr 2019 09:31:36 +0800 Subject: [PATCH] Add test for `addRoute` hook --- app/Services/Hook.php | 4 +--- tests/ServicesTest/HookTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Services/Hook.php b/app/Services/Hook.php index 07a0937b..d6c5a685 100644 --- a/app/Services/Hook.php +++ b/app/Services/Hook.php @@ -48,11 +48,9 @@ class Hook } /** - * Add a route. A router instance will be passed to the given callback. + * Add routes. 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 index 3f5426f7..83233e29 100644 --- a/tests/ServicesTest/HookTest.php +++ b/tests/ServicesTest/HookTest.php @@ -35,6 +35,15 @@ class HookTest extends TestCase ->assertSee('/to/b'); } + public function testAddRoute() + { + Hook::addRoute(function ($route) { + $route->any('/test-hook', function () {}); + }); + event(new \App\Events\ConfigureRoutes(resolve(\Illuminate\Routing\Router::class))); + $this->get('/test-hook')->assertSuccessful(); + } + public function testRegisterPluginTransScripts() { $this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']);