You are here

private function TaxonomyEdgeTreeTestCase::treeInit in Taxonomy Edge 6

Same name and namespace in other branches
  1. 8 tests/tree.test \TaxonomyEdgeTreeTestCase::treeInit()
  2. 7 tests/tree.test \TaxonomyEdgeTreeTestCase::treeInit()
1 call to TaxonomyEdgeTreeTestCase::treeInit()
TaxonomyEdgeTreeTestCase::setUp in tests/tree.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…

File

tests/tree.test, line 330

Class

TaxonomyEdgeTreeTestCase
@file

Code

private function treeInit() {

  // Create a vocabulary.
  $vocabulary = new stdClass();
  $vocabulary->name = 'taxonomy_edge_test1';
  $vocabulary->description = 'taxonomy_edge_test1';
  $vocabulary->help = '';
  $vocabulary = (array) $vocabulary;
  taxonomy_save_vocabulary($vocabulary);
  $this->vocabulary = $vocabulary;
  $tree = array();
  $tree[] = "test1";
  $tree[] = "test1/test2";
  $tree[] = "test1/test2/test3";
  $tree[] = "test1/test4";
  $tree[] = "test1/test4/test5";
  $tree[] = "sub1";
  $tree[] = "sub2";
  $tree[] = "sub3";
  $terms = array();
  $weight = 0;
  foreach ($tree as $path) {
    $parts = explode('/', $path);
    $name = array_pop($parts);
    $parent = array_pop($parts);
    $term = array();
    $term['name'] = $name;
    $term['vid'] = $vocabulary['vid'];
    $term['parent'] = $parent ? $terms[$parent]['tid'] : 0;
    $term['weight'] = $weight++;
    taxonomy_save_term($term);
    $terms[$name] = $term;
  }
  $this->terms = $terms;
}