예제 #1
0
 public function test_group_can_be_cached()
 {
     $item = new DefaultItem($this->container);
     $this->group->addItem($item);
     $serialized = serialize($this->group);
     $unserialized = unserialize($serialized);
     $this->assertInstanceOf('Maatwebsite\\Sidebar\\Group', $unserialized);
     $this->assertInstanceOf('Illuminate\\Support\\Collection', $unserialized->getItems());
     $this->assertCount(1, $unserialized->getItems());
 }
 /**
  * @param Menu $menu
  *
  * @return Menu
  */
 public function extendWith(Menu $menu)
 {
     $container = m::mock('Illuminate\\Contracts\\Container\\Container');
     $group = new DefaultGroup($container);
     $group->name('new from extender');
     $menu->addGroup($group);
     $group = new DefaultGroup($container);
     $group->name('original');
     $menu->addGroup($group);
     return $menu;
 }
예제 #3
0
 public function test_can_combined_menu_instances()
 {
     // Add group to original menu
     $group = new DefaultGroup($this->container);
     $group->name('existing');
     $group->weight(2);
     $this->menu->addGroup($group);
     // Init new menu
     $menu = new DefaultMenu($this->container);
     // Add a new one
     $group = new DefaultGroup($this->container);
     $group->name('new menu group');
     $group->weight(1);
     $menu->addGroup($group);
     // Append to existing
     $group = new DefaultGroup($this->container);
     $group->name('existing');
     $group->weight(2);
     $menu->addGroup($group);
     $this->menu->add($menu);
     $this->assertInstanceOf('Illuminate\\Support\\Collection', $this->menu->getGroups());
     $this->assertCount(2, $this->menu->getGroups());
     $this->assertEquals('new menu group', $this->menu->getGroups()->first()->getName());
 }