Ejemplo n.º 1
0
 /**
  * @covers \BackBee\NestedNode\Repository\PageRepository::moveAsLastChildOf
  * @covers \BackBee\NestedNode\Repository\PageRepository::moveAsChildOf
  * @covers \BackBee\NestedNode\Repository\PageRepository::movePageAsChildOf
  * @covers \BackBee\NestedNode\Repository\PageRepository::moveSectionAsChildOf
  */
 public function testMoveAsLastChidOf()
 {
     $section1 = $this->repository->find('section1');
     $section2 = $this->repository->find('section2');
     $page1 = $this->repository->find('page1');
     $page2 = $this->repository->find('page2');
     $this->assertEquals($page2, $this->repository->moveAsLastChildOf($page2, $section2));
     self::$em->refresh($section2);
     self::$em->refresh($page1);
     self::$em->flush($page2);
     $this->assertEquals($section2, $page2->getParent());
     $this->assertEquals(1, $page2->getPosition());
     $this->assertEquals(2, $page2->getLevel());
     $this->assertEquals(1, $page1->getPosition());
     $this->assertEquals($section2, $this->repository->moveAsFirstChildOf($section2, $section1));
     self::$em->refresh($section1);
     self::$em->refresh($page1);
     self::$em->refresh($page2);
     $this->assertEquals($section1, $section2->getParent());
     $this->assertEquals(2, $section2->getLevel());
     $this->assertEquals(3, $section2->getLeftnode());
     $this->assertEquals(4, $section2->getRightnode());
     $this->assertEquals(2, $section1->getLeftnode());
     $this->assertEquals(5, $section1->getRightnode());
     $this->assertEquals(3, $page2->getLevel());
 }