You are here

function TaxonomyEdgeTreeTestCase::testTerm in Taxonomy Edge 8

Same name and namespace in other branches
  1. 6 tests/tree.test \TaxonomyEdgeTreeTestCase::testTerm()
  2. 7 tests/tree.test \TaxonomyEdgeTreeTestCase::testTerm()

File

tests/tree.test, line 54

Class

TaxonomyEdgeTreeTestCase
@file

Code

function testTerm() {
  $terms =& $this->terms;
  $term = clone $terms['sub3'];
  unset($term->tid);
  $term->name = 'sub4';
  $term->weight--;
  taxonomy_term_save($term);
  $tree = $this
    ->formatTree();
  $expect = "test1\n- test2\n-- test3\n- test4\n-- test5\nsub1\nsub2\nsub4\nsub3\n";
  $match = $tree == $expect;
  $message = "Add 'sub4' to tree" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
  $this
    ->assertTRUE($match, $message);
  taxonomy_term_delete($terms['test1']->tid);
  $tree = $this
    ->formatTree();
  $expect = "sub1\nsub2\nsub4\nsub3\n";
  $match = $tree == $expect;
  $message = "Remove 'sub1' from tree" . ($match ? "" : "\n<pre>Assumed:\n{$expect}\nGot:\n{$tree}");
  $this
    ->assertTRUE($match, $message);
}