コード例 #1
0
ファイル: PageTest.php プロジェクト: gobjila/BackBee
 /**
  * @covers BackBee\NestedNode\Page::getLeftnode()
  * @covers BackBee\NestedNode\Page::getRightnode()
  */
 public function testGetNode()
 {
     $this->assertEquals(1, $this->page->getLeftnode());
     $this->assertEquals(2, $this->page->getRightnode());
     $child = new Page('child');
     $child->setSection($this->page->getSection());
     $this->assertEquals(1, $child->getLeftnode());
     $this->assertEquals(2, $child->getRightnode());
 }
コード例 #2
0
 /**
  * @covers \BackBee\NestedNode\Repository\PageQueryBuilder::andParentIs
  */
 public function testParentIs()
 {
     $root = new Page('root');
     $child = new Page('child');
     $child->setSection($root->getSection());
     $q = $this->repository->createQueryBuilder('p')->andParentIs();
     $this->assertInstanceOf('BackBee\\NestedNode\\Repository\\PageQueryBuilder', $q);
     $this->assertEquals('SELECT p FROM BackBee\\NestedNode\\Page p INNER JOIN p._section p_s WHERE p_s._parent IS NULL AND p_s = p', $q->getDql());
     $q->resetDQLPart('where')->andParentIs($child);
     $this->assertEquals('SELECT p FROM BackBee\\NestedNode\\Page p INNER JOIN p._section p_s WHERE 1 = 0', $q->getDql());
     $q->resetDQLPart('where')->andParentIs($root);
     $this->assertEquals('SELECT p FROM BackBee\\NestedNode\\Page p INNER JOIN p._section p_s WHERE (p_s._parent = :parent0 OR p._section = :parent0) AND p._level = :level0', $q->getDql());
     $this->assertEquals($root->getSection(), $q->getParameter('parent0')->getValue());
     $this->assertEquals($root->getLevel() + 1, $q->getParameter('level0')->getValue());
 }