Add test for addRoute hook

This commit is contained in:
Pig Fang 2019-04-05 09:31:36 +08:00
parent b9c2cdff6b
commit 293668960a
2 changed files with 10 additions and 3 deletions

View File

@ -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 * @param Closure $callback
*
* TODO: Needs to be tested.
*/ */
public static function addRoute(Closure $callback) public static function addRoute(Closure $callback)
{ {

View File

@ -35,6 +35,15 @@ class HookTest extends TestCase
->assertSee('/to/b'); ->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() public function testRegisterPluginTransScripts()
{ {
$this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']); $this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']);