/** * @covers \BackBee\NestedNode\Repository\NestedNodeQueryBuilder::andIsSiblingsOf */ public function testAndIsSiblingsOf() { $q = $this->repository->createQueryBuilder('n')->andIsSiblingsOf($this->root); $this->assertInstanceOf('BackBee\\NestedNode\\Repository\\NestedNodeQueryBuilder', $q); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid = :uid0 AND n._parent IS NULL ORDER BY n._leftnode asc', $q->getDql()); $this->assertEquals($this->root->getUid(), $q->getParameter('uid0')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($this->root, true); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid != :uid0 AND n._uid = :uid1 AND n._parent IS NULL ORDER BY n._leftnode asc', $q->getDql()); $this->assertEquals($this->root->getUid(), $q->getParameter('uid0')->getValue()); $this->assertEquals($this->root->getUid(), $q->getParameter('uid1')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($this->root, null, array('_rightnode' => 'desc')); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid = :uid0 AND n._parent IS NULL ORDER BY n._rightnode desc', $q->getDql()); $this->assertEquals($this->root->getUid(), $q->getParameter('uid0')->getValue()); $child1 = $this->repository->find('child1'); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($child1); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._parent = :parent0 ORDER BY n._leftnode asc', $q->getDql()); $this->assertEquals($this->root, $q->getParameter('parent0')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($child1, true); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid != :uid0 AND n._parent = :parent1 ORDER BY n._leftnode asc', $q->getDql()); $this->assertEquals($child1->getUid(), $q->getParameter('uid0')->getValue()); $this->assertEquals($this->root, $q->getParameter('parent1')->getValue()); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($child1, true, array('_rightnode' => 'desc'), 10); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid != :uid0 AND n._parent = :parent1 ORDER BY n._rightnode desc', $q->getDql()); $this->assertEquals($child1->getUid(), $q->getParameter('uid0')->getValue()); $this->assertEquals($this->root, $q->getParameter('parent1')->getValue()); $this->assertEquals(10, $q->getMaxResults()); $this->assertEquals(0, $q->getFirstResult()); $q->resetDQLPart('where')->setParameters(array())->andIsSiblingsOf($child1, true, array('_rightnode' => 'desc'), 10, 5); $this->assertEquals('SELECT n FROM BackBee\\NestedNode\\Tests\\Mock\\MockNestedNode n WHERE n._uid != :uid0 AND n._parent = :parent1 ORDER BY n._rightnode desc', $q->getDql()); $this->assertEquals($child1->getUid(), $q->getParameter('uid0')->getValue()); $this->assertEquals($this->root, $q->getParameter('parent1')->getValue()); $this->assertEquals(10, $q->getMaxResults()); $this->assertEquals(5, $q->getFirstResult()); }
/** * @covers BackBee\NestedNode\AbstractNestedNode::setUid */ public function testSetUid() { $this->assertEquals($this->mock, $this->mock->setUid('new-uid')); $this->assertEquals('new-uid', $this->mock->getUid()); }