/** * findMenuIdOnMap * * @param string $itemId menu item object id * * @return string */ protected function findMenuIdOnMap($itemId) { $menuMap = $this->cache->getMenuMap(); if (isset($menuMap[$itemId])) { $menuId = $menuMap[$itemId]; if ($menuId !== null) { return $menuId; } } $menuId = $this->menuRepository->getMenuIdByItem($itemId); return $menuId; }
/** * testGetMenuIdByItemException * * @return void */ public function testGetMenuIdByItemException() { $this->setExpectedException('Xpressengine\\Menu\\Exceptions\\NotFoundMenuException'); $conn = $this->getConnectionMock(); $keygen = $this->getKeygenMock(); $nodeTableQuery = $this->getQueryBuilderMock(); $conn->shouldReceive('table')->with(self::MENU_TREE_PATH_TABLE)->andReturn($nodeTableQuery); $nodeTableQuery->shouldReceive('where')->andReturn($nodeTableQuery); $nodeTableQuery->shouldReceive('orderBy')->andReturn($nodeTableQuery); $nodeTableQuery->shouldReceive('select')->andReturn($nodeTableQuery); $nodeTableQuery->shouldReceive('first')->andReturn(null); $menuRepo = new DBMenuRepository($conn, $keygen); $menuRepo->getMenuIdByItem('notice'); }