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