public function testDelete() { list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); /* Tree used for tests t1 | \ t2 t3 | \ t4 t5 | \ t6 t7 */ $t5->delete(); $this->assertEquals(13, $t3->getRightValue(), 'delete() does not update existing nodes (because delete() clears the instance cache)'); $expected = array('t1' => array(1, 8, 0), 't2' => array(2, 3, 1), 't3' => array(4, 7, 1), 't4' => array(5, 6, 2)); $this->assertEquals($expected, $this->dumpTree(), 'delete() deletes all descendants and shifts the entire subtree correctly'); list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); try { $t1->delete(); $this->fail('delete() throws an exception when called on a root node'); } catch (PropelException $e) { $this->assertTrue(true, 'delete() throws an exception when called on a root node'); } $this->assertNotEquals(array(), Table9Peer::doSelect(new Criteria()), 'delete() called on the root node does not delete the whole tree'); }
public function testDeleteTree() { $this->initTree(); Table9Peer::deleteTree(); $this->assertEquals(array(), Table9Peer::doSelect(new Criteria()), 'deleteTree() deletes the whole tree'); }
protected function dumpTree() { $c = new Criteria(); $c->addAscendingOrderBycolumn(Table9Peer::TITLE); return $this->dumpNodes(Table9Peer::doSelect($c)); }