/** * Test load from cache cache */ public function testFullCache() { $node = new Node(); $node->setSubnodes(new ArrayCollection())->setId(1); $menu = new Menu(); $menu->setSubnodes(new ArrayCollection())->addSubnode($node); $this->menuRepository->expects($this->any())->method('findOneBy'); $this->cacheProvider->expects($this->once())->method('fetch')->will($this->returnValue('{"1":{"id":1,"name":null,"url":null,"subnodes":[]}}')); $this->cacheProvider->expects($this->any())->method('save'); /** * Data is required twice to test how many times data is fetched from * cache provider, and to test than both times, returned data is the * same */ $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]); $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]); }
/** * Test load structure. */ public function testLoadFrontMenu() { $this->assertInstanceOf('Elcodi\\Component\\Menu\\Entity\\Menu\\Interfaces\\MenuInterface', $this->menuManager->loadMenuByCode('menu-front')); }
/** * Test load structure */ public function testLoadFrontMenu() { $this->assertEquals($this->menuManager->loadMenuByCode('menu-front'), [2 => ['id' => 2, 'name' => 'him', 'code' => 'him', 'url' => 'elcodi.dev/him', 'subnodes' => []], 3 => ['id' => 3, 'name' => 'her', 'code' => 'her', 'url' => 'elcodi.dev/her', 'subnodes' => []]]); }