/** * @covers \BackBee\NestedNode\Repository\NestedNodeQueryBuilder::andIsDescendantOf */ public function testAndIsDescendantOf() { $child1 = $this->repository->find('child1'); $q = $this->repository->createQueryBuilder('n')->andIsDescendantOf($child1); $this->assertInstanceOf('BackBee\\NestedNode\\Repository\\NestedNodeQueryBuilder', $q); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._root = :root0 AND n._leftnode >= :leftnode1 AND n._rightnode <= :rightnode2', $q->getDql()); $this->assertEquals($this->root, $q->getParameter('root0')->getValue()); $this->assertEquals($child1->getLeftnode(), $q->getParameter('leftnode1')->getValue()); $this->assertEquals($child1->getRightnode(), $q->getParameter('rightnode2')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsDescendantOf($child1, true); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._root = :root0 AND n._leftnode >= :leftnode1 AND n._rightnode <= :rightnode2', $q->getDql()); $this->assertEquals($this->root, $q->getParameter('root0')->getValue()); $this->assertEquals($child1->getLeftnode() + 1, $q->getParameter('leftnode1')->getValue()); $this->assertEquals($child1->getRightnode() - 1, $q->getParameter('rightnode2')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsDescendantOf($child1, true, 1); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._root = :root0 AND n._leftnode >= :leftnode1 AND n._rightnode <= :rightnode2 AND n._level = :level3', $q->getDql()); $this->assertEquals($this->root, $q->getParameter('root0')->getValue()); $this->assertEquals($child1->getLeftnode() + 1, $q->getParameter('leftnode1')->getValue()); $this->assertEquals($child1->getRightnode() - 1, $q->getParameter('rightnode2')->getValue()); $this->assertEquals(1, $q->getParameter('level3')->getValue()); }
/** * @covers \BackBee\NestedNode\Repository\NestedNodeRepository::moveAsNextSiblingOf * @expectedException \BackBee\Exception\InvalidArgumentException */ public function testMoveAsNextSiblingOfRoot() { $source = $this->repository->find('a-child1'); $this->repository->moveAsNextSiblingOf($source, $this->root_asc); }