Fix big offset for Hook::addMenuItem
This commit is contained in:
parent
f1378367d7
commit
7ec7eb2467
|
|
@ -39,6 +39,10 @@ class Hook
|
|||
$offset++;
|
||||
}
|
||||
|
||||
if ($position >= $offset) {
|
||||
$new[] = $menu;
|
||||
}
|
||||
|
||||
$event->menu[$category] = $new;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,15 +13,26 @@ class HookTest extends TestCase
|
|||
public function testAddMenuItem()
|
||||
{
|
||||
Hook::addMenuItem('user', 0, [
|
||||
'title' => 'Go to closet',
|
||||
'link' => '/user/closet',
|
||||
'title' => 'Link A',
|
||||
'link' => '/to/a',
|
||||
'icon' => 'fa-book'
|
||||
]);
|
||||
$this->actAs('normal')
|
||||
->get('/user')
|
||||
->assertSee('Go to closet')
|
||||
->assertSee('/user/closet')
|
||||
->assertSee('Link A')
|
||||
->assertSee('/to/a')
|
||||
->assertSee('fa-book');
|
||||
|
||||
// Out of bound
|
||||
Hook::addMenuItem('user', 10, [
|
||||
'title' => 'Link B',
|
||||
'link' => '/to/b',
|
||||
'icon' => 'fa-book'
|
||||
]);
|
||||
$this->actAs('normal')
|
||||
->get('/user')
|
||||
->assertSee('Link B')
|
||||
->assertSee('/to/b');
|
||||
}
|
||||
|
||||
public function testRegisterPluginTransScripts()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user