'Link A',
'link' => '/to/a',
'icon' => 'fa-book',
'new-tab' => true,
]);
$this->actingAs(factory(User::class)->create())
->get('/user')
->assertSee('Link A')
->assertSee('/to/a')
->assertSee('target="_blank"', false)
->assertSee('fa-book');
// Out of bound
Hook::addMenuItem('user', 10, [
'title' => 'Link B',
'link' => '/to/b',
'icon' => 'fa-book',
]);
$this->actingAs(factory(User::class)->create())
->get('/user')
->assertSee('Link 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()
{
Hook::registerPluginTransScripts('fake-plugin-with-i18n', ['/']);
$this->get('/')->assertSee('fake-plugin-with-i18n/lang/en/locale.js');
$this->get('/skinlib')->assertDontSee('fake-plugin-with-i18n/lang/en/locale.js');
}
public function testAddStyleFileToPage()
{
Hook::addStyleFileToPage('/style/all');
$this->get('/')
->assertSee('', false);
Hook::addStyleFileToPage('/style/pattern', ['skinlib']);
$this->get('/')
->assertDontSee('');
$this->get('/skinlib')
->assertSee('', false);
}
public function testAddScriptFileToPage()
{
Hook::addScriptFileToPage('/script/all');
$this->get('/')
->assertSee('', false);
Hook::addScriptFileToPage('/script/pattern', ['skinlib']);
$this->get('/')
->assertDontSee('');
$this->get('/skinlib')
->assertSee('', false);
}
public function testAddUserBadge()
{
Hook::addUserBadge('hi', 'green');
$this->actingAs(factory(User::class)->create())
->get('/user')
->assertSee('hi', false);
}
public function testSendNotification()
{
$user = factory(User::class)->create();
Hook::sendNotification([$user], 'Ibara Mayaka');
$user->refresh();
$this->assertCount(1, $user->unreadNotifications);
}
public function testPushMiddleware()
{
Hook::pushMiddleware(Concerns\FakeMiddleware::class);
$this->get('/')->assertHeader('X-Middleware-Test');
}
}