/** * @covers DoctrineExtensions\NestedSet\NodeWrapper::insertAsPrevSiblingOf * @covers DoctrineExtensions\NestedSet\NodeWrapper::shiftRLRange * @covers DoctrineExtensions\NestedSet\NodeWrapper::insertNode */ public function testInsertAsPrevSiblingOf() { $newNode = new NodeWrapper(new SingleRootNodeMock(21, '1.1.1(.5)'), $this->nsm); $newNode->insertAsPrevSiblingOf($this->wrappers[3]); $this->assertEquals(5, $newNode->getLeftValue(), '->insertAsPrevSiblingOf() updates new node\'s left value'); $this->assertEquals(6, $newNode->getRightValue(), '->insertAsPrevSiblingOf() updates new node\'s right value'); $this->assertEquals(3, $this->wrappers[2]->getLeftValue(), '->insertAsPrevSiblingOf updates prev node\'s left value'); $this->assertEquals(4, $this->wrappers[2]->getRightValue(), '->insertAsPrevSiblingOf updates prev node\'s right value'); $this->assertEquals(7, $this->wrappers[3]->getLeftValue(), '->insertAsPrevSiblingOf updates next node\'s left value'); $this->assertEquals(8, $this->wrappers[3]->getRightValue(), '->insertAsPrevSiblingOf updates next node\'s right value'); }
/** * @covers DoctrineExtensions\NestedSet\NodeWrapper::insertAsLastChildOf * @covers DoctrineExtensions\NestedSet\NodeWrapper::shiftRLRange * @covers DoctrineExtensions\NestedSet\NodeWrapper::insertNode */ public function testInsertAsLastChildOf() { $newNode = new NodeWrapper(new NodeMock(21, '1.1.3'), $this->nsm); $newNode->insertAsLastChildOf($this->wrappers[1]); $this->assertEquals(7, $newNode->getLeftValue(), '->insertAsLastChildOf() updates new node\'s left value'); $this->assertEquals(8, $newNode->getRightValue(), '->insertAsLastChildOf() updates new node\'s right value'); $this->assertEquals(2, $this->wrappers[1]->getLeftValue(), '->insertAsLastChildOf updates parent node\'s left value'); $this->assertEquals(9, $this->wrappers[1]->getRightValue(), '->insertAsLastChildOf updates parent node\'s right value'); $this->assertEquals(5, $this->wrappers[3]->getLeftValue(), '->insertAsLastChildOf doesn\'t update last child node\'s left value'); $this->assertEquals(6, $this->wrappers[3]->getRightValue(), '->insertAsLastChildOf doesn\'t update last child node\'s right value'); }