Skip to content

Commit

Permalink
Rename test classes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/DB_NestedSet/trunk@318854 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
CloCkWeRX committed Nov 6, 2011
1 parent dd481aa commit 6c2b90c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 63 deletions.
29 changes: 14 additions & 15 deletions tests/api.php
@@ -1,5 +1,5 @@
<?php
class tests_NestedSet_api extends DB_NestedSetTest {
class DB_NestedSet_APITest extends DB_NestedSetTest {

function test_sortMethods() {

Expand All @@ -9,29 +9,29 @@ function test_sortMethods() {
$values['STRNA'] = 'Skireisen';
$skireisen = $this->_NeSe->createRootNode($values, false, true);


$values['STRNA'] = 'Schweiz';
$schweiz = $this->_NeSe->createSubNode($skireisen, $values);
$values['STRNA'] = 'Grindelwald';
$grindelwald = $this->_NeSe->createSubNode($schweiz, $values);



$values['STRNA'] = 'Österreich';
$oesterreich = $this->_NeSe->createSubNode($skireisen, $values);
$values['STRNA'] = 'Arlberg';
$arlberg = $this->_NeSe->createSubNode($oesterreich, $values);
$values['STRNA'] = 'Saalbach';
$saalbach = $this->_NeSe->createSubNode($oesterreich, $values);
$values['STRNA'] = 'Obertauern';
$obertauern = $this->_NeSe->createSubNode($oesterreich, $values);
$obertauern = $this->_NeSe->createSubNode($oesterreich, $values);

$values['STRNA'] = 'Italien';
$italien = $this->_NeSe->createSubNode($skireisen, $values);
$values['STRNA'] = 'Meransen';
$meransen = $this->_NeSe->createSubNode($italien, $values);


echo "DEFAULT\n";
$this->_NeSe->setSortMode(NESE_SORT_LEVEL);
$allnodes_default = $this->_NeSe->getAllNodes(true);
Expand Down Expand Up @@ -59,28 +59,28 @@ function test_sortMethods() {
$this->_NeSe->setSortMode(NESE_SORT_PREORDER);
$this->_NeSe->secondarySort = 'STRNA';
$allnodes_preorder = $this->_NeSe->getSubBranch($oesterreich, true);
$this->_indentTree($allnodes_preorder);
$this->_indentTree($allnodes_preorder);

echo "BY NAME PREORDER getSubBranch empty subbranch\n";
$this->_NeSe->setSortMode(NESE_SORT_PREORDER);
$this->_NeSe->secondarySort = 'STRNA';
$allnodes_preorder = $this->_NeSe->getSubBranch($grindelwald, true);
$this->_indentTree($allnodes_preorder);
$this->_indentTree($allnodes_preorder);



echo "TRYING getBranch()\n";
$atbranch = $this->_NeSe->getBranch($oesterreich, true);
$this->_indentTree($atbranch);

echo "TRYING getChildren()\n";
$atbranch = $this->_NeSe->getChildren($oesterreich, true);
$this->_indentTree($atbranch);

echo "TRYING getSubBranch()\n";
$atbranch = $this->_NeSe->getSubBranch($skireisen, true);
$this->_indentTree($atbranch);
echo "</code>";
echo "</code>";
}

function test_convertModel() {
Expand All @@ -93,5 +93,4 @@ function test_convertModel() {
$this->_NeSe2->setSortMode(NESE_SORT_LEVEL);
$this->assertEquals($this->_NeSe->getAllNodes(true), $this->_NeSe2->getAllNodes(true), 'Converted tree should match original');
}
}
?>
}
16 changes: 8 additions & 8 deletions tests/creation.php
Expand Up @@ -10,7 +10,7 @@
*/


class tests_NestedSet_creation extends DB_NestedSetTest {
class DB_NestedSet_CreationTest extends DB_NestedSetTest {


// +----------------------------------------------+
Expand Down Expand Up @@ -85,10 +85,10 @@ function test_createRightNode() {
$values['STRNA'] = 'RS'.$x;
$sid = $this->_NeSe->createSubNode($rn1, $values);
$values['STRNA'] = 'RSR'.$x;

// Test quoting of reserved words
$values['key'] = 'SELECT';

// Try to overwrite the ROOTID which should be set inside the method
// $values['ROOTID'] = -100;
$rn2 = $this->_NeSe->createRightNode($sid, $values, true);
Expand Down Expand Up @@ -152,8 +152,8 @@ function test_createLeftNode() {
$sid = $this->_NeSe->createSubNode($rn1, $values);
$values['STRNA'] = 'RSR'.$x;
// Test quoting of reserved words
$values['key'] = 'SELECT';
$values['key'] = 'SELECT';

// Try to overwrite the ROOTID which should be set inside the method
// $values['ROOTID'] = -100;
$rn2 = $this->_NeSe->createLeftNode($sid, $values);
Expand Down Expand Up @@ -216,8 +216,8 @@ function test_createNodes__random() {
$this->_createRandomNodes(3, 150);
return true;
}



}
?>
78 changes: 39 additions & 39 deletions tests/manipulation.php
Expand Up @@ -9,14 +9,14 @@
* @access public
*/

class tests_NestedSet_manipulation extends DB_NestedSetTest {
class DB_NestedSet_ManipulationTest extends DB_NestedSetTest {

// +----------------------------------------------+
// | Testing manipulation methods |
// |----------------------------------------------+
// | [PUBLIC] |
// +----------------------------------------------+


/**
* tests_NestedSet_common::test_deleteNode()
Expand All @@ -29,20 +29,20 @@ class tests_NestedSet_manipulation extends DB_NestedSetTest {
* @return bool True on completion
*/
function test_deleteNode() {

$relationTree = $this->_createRandomNodes(3, 150);
$rootnodes = $this->_NeSe->getRootNodes(true);

foreach($rootnodes as $rid=>$rootnode) {

$this->_deleteNodes($rid, true);
$rn = $this->_NeSe->pickNode($rid, true);
$this->assertEquals(1, $rn['l'], 'Wrong LFT value');
$this->assertEquals(2, $rn['r'], 'Wrong RGT value');
}
return true;
}

/**
* tests_NestedSet_common::test_updateNode()
*
Expand All @@ -66,115 +66,115 @@ function test_updateNode() {
}
return true;
}

function test_rootUnderRoot() {
$rootnodes = $this->_createRootNodes(3);

$ret = $this->_NeSe->moveTree($rootnodes[1]['id'], $rootnodes[2]['id'], NESE_MOVE_BELOW);

$source = $this->_NeSe->pickNode($rootnodes[1]['id'], true);
$parent = $this->_NeSe->getParent($rootnodes[1]['id'], true, true, array(), false);
$target = $this->_NeSe->pickNode($rootnodes[2]['id'], true);
$this->assertEquals($target['id'], $source['parent'], 'Parent id from column is wrong');
$this->assertEquals($target['id'], $parent['id'], 'Calculated parent id is wrong');
return true;
}

function test_moveTree() {

// $movemodes[] = NESE_MOVE_BEFORE;
$movemodes[] = NESE_MOVE_AFTER;
$movemodes[] = NESE_MOVE_BELOW;
for($j = 0; $j < count($movemodes); $j ++) {

$mvt = $movemodes[$j];

// Build a nice random tree
$rnc = 2;
$depth = 3;
$npl = 2;
$relationTree = $this->_createSubNode($rnc, $depth, $npl);

$lastrid = false;
$rootnodes = $this->_NeSe->getRootNodes(true);
$branches = array();
$allnodes1 = $this->_NeSe->getAllNodes(true);
foreach($rootnodes as $rid=>$rootnode) {

if($lastrid) {
$this->_NeSe->moveTree($rid, $lastrid, $mvt);
}

$branch = $this->_NeSe->getBranch($rid, true);
if(! empty($branch)) {
$branches[] = $branch;
}

if(count($branches) == 2) {
$this->_moveTree__Across($branches, $mvt, count($this->_NeSe->getAllNodes(true)));
$branches = array();
}
$lastrid = $rid;
}

$allnodes2 = $this->_NeSe->getAllNodes(true);
// Just make sure that all the nodes are still there
$this->assertEquals(0, count(array_diff(array_keys($allnodes1), array_keys($allnodes2))), 'Nodes got lost during the move');
}
return true;
}

function test_copyTree() {

$values['STRNA'] = 'Root1';
$root1 = $this->_NeSe->createRootnode($values, false, true);

$values['STRNA'] = 'Root2';
$root2 = $this->_NeSe->createRightNode($root1, $values);
$values['STRNA'] = 'Sub2-1';
$sub2_1 = $this->_NeSe->createSubNode($root2, $values);

$values['STRNA'] = 'Root2';
$root3 = $this->_NeSe->createRightNode($root2, $values);
$values['STRNA'] = 'Sub3-1';
$sub3_1 = $this->_NeSe->createSubNode($root3, $values);

// Copy a Rootnode
$root2_copy = $this->_NeSe->moveTree($root2, $root1, NESE_MOVE_BEFORE, true);
$this->assertFalse($root2_copy == $root2, 'Copy returned wrong node id');

$nroot2_copy = $this->_NeSe->pickNode($root2_copy, true);
$this->assertEquals($root2_copy, $nroot2_copy['id'], 'Copy created wrong node array');

// Copy another Rootnode
$root2_copy = $this->_NeSe->moveTree($root2, $root1, NESE_MOVE_AFTER, true);
$this->assertFalse($root2_copy == $root2, 'Copy returned wrong node id');

$nroot2_copy = $this->_NeSe->pickNode($root2_copy, true);
$this->assertEquals($root2_copy, $nroot2_copy['id'], 'Copy created wrong node array');

// Copy tree below another Rootnode
$root2_copy = $this->_NeSe->moveTree($root2, $root1, NESE_MOVE_BELOW, true);
$this->assertFalse($root2_copy == $root2, 'Copy returned wrong node id');

$nroot2_copy = $this->_NeSe->pickNode($root2_copy, true);
$this->assertEquals($root2_copy, $nroot2_copy['id'], 'Copy created wrong node array');

// Copy subtree below another Rootnode
$sub3_1_copy = $this->_NeSe->moveTree($sub3_1, $root1, NESE_MOVE_BELOW, true);
$this->assertFalse($sub3_1_copy == $sub3_1, 'Copy returned wrong node id');

$nsub3_1_copy = $this->_NeSe->pickNode($sub3_1_copy, true);
$this->assertEquals($sub3_1_copy, $nsub3_1_copy['id'], 'Copy created wrong node array');
}

/*
* Couldn' reproduce this
*
*
*/
function test_13166_wrong_child_order() {
// $this->_NeSe->setSortMode(NESE_SORT_PREORDER);

$values = array();
$values['STRNA'] = 'root';
$root = $this->_NeSe->createRootnode($values);
Expand All @@ -186,23 +186,23 @@ function test_13166_wrong_child_order() {
$node_3 = $this->_NeSe->createSubNode($root, $values);
$tree = $this->_NeSe->getAllNodes(true);

$this->_indentTree($tree);
$this->_indentTree($tree);

$this->_NeSe->deleteNode($node_2);
$tree = $this->_NeSe->getAllNodes(true);
$this->_indentTree($tree);
$values['STRNA'] = 'node_2';
$node_2 = $this->_NeSe->createLeftNode($node_3, $values);
$values['STRNA'] = 'node_22';
$node_22 = $this->_NeSe->createLeftNode($node_2, $values);
$node_22 = $this->_NeSe->createLeftNode($node_2, $values);

$tree = $this->_NeSe->getAllNodes(true);

$this->_indentTree($tree);
}



function test_12341_rootnode_leftright_bug() {
$this->_NeSe->setSortMode(NESE_SORT_PREORDER);
$values = array();
Expand Down
2 changes: 1 addition & 1 deletion tests/query.php
Expand Up @@ -9,7 +9,7 @@
* @access public
*/

class tests_NestedSet_query extends DB_NestedSetTest {
class DB_NestedSet_QueryTest extends DB_NestedSetTest {
// +----------------------------------------------+
// | Testing query methods |
// |----------------------------------------------+
Expand Down

0 comments on commit 6c2b90c

Please sign in to comment.