function TaxonomyTermFunctions::testTermsFunctionsSingleHierarchy in SimpleTest 5        
                          
                  
                        Same name and namespace in other branches
- 6 tests/taxonomy.module.test \TaxonomyTermFunctions::testTermsFunctionsSingleHierarchy()
File
 
   - tests/taxonomy.module.test, line 155
Class
  
  - TaxonomyTermFunctions 
Code
function testTermsFunctionsSingleHierarchy() {
  
  
  $edit = array();
  $_t = array(
    'vid',
    'name',
    'description',
    'help',
    'relations',
    'hierarchy',
    'multiple',
    'required',
    'tags',
    'module',
    'weight',
    'nodes',
  );
  foreach ($_t as $key) {
    $edit[$key] = 0;
  }
  
  $name = $this
    ->randomName(20);
  $edit['hierarchy'] = 1;
  $edit['name'] = $name;
  taxonomy_save_vocabulary($edit);
  
  $termname = $this
    ->randomName(20);
  $data = array(
    'name' => $termname,
    'description' => '',
    'weight' => 0,
    'synonyms' => '',
    'vid' => $edit['vid'],
    'tid' => 0,
    'relations' => 0,
  );
  taxonomy_save_term($data);
  $_tArray = taxonomy_get_term_by_name($termname);
  $parent = $_tArray[0];
  
  $termname = $this
    ->randomName(20);
  $data = array(
    'name' => $termname,
    'description' => '',
    'weight' => 0,
    'synonyms' => '',
    'vid' => $edit['vid'],
    'tid' => 0,
    'relations' => 0,
    'parent' => array(
      $parent->tid,
    ),
  );
  taxonomy_save_term($data);
  $_tArray = taxonomy_get_term_by_name($termname);
  $children = $_tArray[0];
  
  $getChildren = taxonomy_get_children($parent->tid);
  $getParent = taxonomy_get_parents($children->tid);
  $this
    ->assertEqual($parent, $getParent[$parent->tid], 'Checking parents');
  $this
    ->assertEqual($children, $getChildren[$children->tid], 'Checking children');
  
  $edit['name'] = 0;
  taxonomy_save_vocabulary($edit);
}