/** * @covers \BackBee\NestedNode\Repository\PageRepository::getVisibleDescendants * @covers \BackBee\NestedNode\Repository\PageRepository::getOrderingDescendants */ public function testGetVisibleDescendants() { $section1 = $this->repository->find('section1'); $section2 = $this->repository->find('section2'); $page1 = $this->repository->find('page1'); $page2 = $this->repository->find('page2'); $page3 = $this->repository->find('page3'); $this->root->setState(Page::STATE_ONLINE); $section2->setState(Page::STATE_ONLINE + Page::STATE_HIDDEN); $section1->setState(Page::STATE_ONLINE); $page1->setState(Page::STATE_ONLINE); $page2->setState(Page::STATE_ONLINE + Page::STATE_HIDDEN); $page3->setState(Page::STATE_ONLINE); self::$em->flush(); $this->assertEquals(array(), $this->repository->getVisibleDescendants($page1)); $this->assertEquals(array($page3, $section1, $page1), $this->repository->getVisibleDescendants($this->root)); $this->assertEquals(array($section1, $page3), $this->repository->getVisibleDescendants($this->root, 1)); $this->assertEquals(array($page3, $section1, $page1), $this->repository->getVisibleDescendants($this->root, 2)); $this->assertEquals(array($this->root, $page3, $section1, $page1), $this->repository->getVisibleDescendants($this->root, 2, true)); $this->assertEquals(array($this->root, $page3, $section1, $page1), $this->repository->getVisibleDescendants($this->root, 2, true, array())); $this->assertEquals(array($page1, $page3, $this->root, $section1), $this->repository->getVisibleDescendants($this->root, 2, true, array('_title' => 'ASC'))); $this->assertEquals(array($this->root, $section1), $this->repository->getVisibleDescendants($this->root, 2, true, array('_title' => 'ASC'), false, null, null, true)); $result = $this->repository->getVisibleDescendants($this->root, 2, true, array(), true, 1, 2); $this->assertInstanceOf('Doctrine\\ORM\\Tools\\Pagination\\Paginator', $result); $this->assertEquals(4, $result->count()); $this->assertEquals(2, $result->getIterator()->count()); $this->assertEquals(1, $result->getQuery()->getFirstResult()); $this->assertEquals(2, $result->getQuery()->getMaxResults()); }