You are here

public function TaxonomyMenuWebTestCase::createTermsHierarchy in Taxonomy menu 7.2

Creates a hierarchy of taxonomy terms for the vocabulary defined in the current class.

@TODO Add multiple parents when taxonomy_menu can deal with it.

Return value

An array of 7 hierarchised taxonomy term objects.

The hierarchy is as follow: terms[1] | depth: 0 -- terms[2] | depth: 1 -- terms[3] | depth: 1 ---- terms[4] | depth: 2 -- terms[5] | depth: 1 terms[6] | depth: 0 -- terms[7] | depth: 1

5 calls to TaxonomyMenuWebTestCase::createTermsHierarchy()
TaxonomyMenuConfigurationTest::setUp in tests/taxonomy_menu.test
Implementation of setUp().
TaxonomyMenuCustomPathConfigurationTest::setUp in taxonomy_menu_custom_paths/tests/taxonomy_menu_custom_paths.test
Implementation of setUp().
TaxonomyMenuCustomPathFunctionalTest::setUp in taxonomy_menu_custom_paths/tests/taxonomy_menu_custom_paths.test
Implementation of setUp().
TaxonomyMenuFunctionalTest::setUp in tests/taxonomy_menu.test
Implementation of setUp().
TaxonomyMenuUnitTest::setUp in tests/taxonomy_menu.test
Implementation of setUp().

File

tests/taxonomy_menu.test, line 65
Defines abstract base test class for the Taxonomy menu module tests.

Class

TaxonomyMenuWebTestCase
Abstract class for Taxonomy menu testing. All Taxonomy menu tests should extend this class.

Code

public function createTermsHierarchy() {
  $terms = array();
  for ($i = 1; $i < 8; $i++) {
    $terms[$i] = $this
      ->createTerm($this->vocabulary);
  }

  // Set the hierarchy by adding parent terms.
  $terms[2]->parent = array(
    $terms[1]->tid,
  );
  taxonomy_term_save($terms[2]);
  $terms[3]->parent = array(
    $terms[1]->tid,
  );
  taxonomy_term_save($terms[3]);
  $terms[4]->parent = array(
    $terms[3]->tid,
  );
  taxonomy_term_save($terms[4]);
  $terms[5]->parent = array(
    $terms[1]->tid,
  );
  taxonomy_term_save($terms[5]);
  $terms[7]->parent = array(
    $terms[6]->tid,
  );
  taxonomy_term_save($terms[7]);
  return $terms;
}