function TaxonomyEdgeTreeTestCase::testTree in Taxonomy Edge 8
Same name and namespace in other branches
- 6 tests/tree.test \TaxonomyEdgeTreeTestCase::testTree()
- 7 tests/tree.test \TaxonomyEdgeTreeTestCase::testTree()
File
- tests/
tree.test, line 92
Class
- TaxonomyEdgeTreeTestCase
- @file
Code
function testTree() {
$terms =& $this->terms;
$vocabulary =& $this->vocabulary;
$vid = $vocabulary->vid;
// Move 'test1' to 'sub1'
$term = $terms['test1'];
$term->parent = $terms['sub1']->tid;
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "sub1\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\nsub2\nsub3\n";
$match = $tree == $expect;
$message = "Move 'test1' to 'sub1'" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Move 'test1' back to root
$term = $terms['test1'];
$term->parent = 0;
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "test1\n- test2\n-- test3\n- test4\n-- test5\nsub1\nsub2\nsub3\n";
$match = $tree == $expect;
$message = "Move 'test1' back to root" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Move 'test1' to 'sub3'
$term = $terms['test1'];
$term->parent = $terms['sub3']->tid;
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "sub1\nsub2\nsub3\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\n";
$match = $tree == $expect;
$message = "Move 'test1' to 'sub3'" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Move 'test1' back to root
$term = $terms['test1'];
$term->parent = 0;
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "test1\n- test2\n-- test3\n- test4\n-- test5\nsub1\nsub2\nsub3\n";
$match = $tree == $expect;
$message = "Move 'test1' back to root" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Copy 'test1' to 'sub2'
$term = $terms['test1'];
$term->parent = array(
0,
$terms['sub2']->tid,
);
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "test1\n- test2\n-- test3\n- test4\n-- test5\nsub1\nsub2\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\nsub3\n";
$match = $tree == $expect;
$message = "Copy 'test1' to 'sub2'" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Remove 'test1' from root
$term = $terms['test1'];
$term->parent = array(
$terms['sub2']->tid,
);
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "sub1\nsub2\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\nsub3\n";
$match = $tree == $expect;
$message = "Remove 'test1' from root" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Copy 'test1' to root
$term = $terms['test1'];
$term->parent = array(
0,
$terms['sub2']->tid,
);
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "test1\n- test2\n-- test3\n- test4\n-- test5\nsub1\nsub2\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\nsub3\n";
$match = $tree == $expect;
$message = "Copy 'test1' to root" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
// Remove 'test1' from root
$term = $terms['test1'];
$term->parent = array(
$terms['sub2']->tid,
);
taxonomy_term_save($term);
$tree = $this
->formatTree();
$expect = "sub1\nsub2\n- test1\n-- test2\n--- test3\n-- test4\n--- test5\nsub3\n";
$match = $tree == $expect;
$message = "Remove 'test1' from root" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
$this
->assertTRUE($match, $message);
}