public function TaxonomyMenuWebTestCase::createTermsHierarchy in Taxonomy menu 8
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
6 calls to TaxonomyMenuWebTestCase::createTermsHierarchy()
- TaxonomyMenuConfigurationTest::setUp in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuConfigurationTest.php - Implementation of setUp().
- TaxonomyMenuCustomPathConfigurationTest::setUp in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuCustomPathConfigurationTest.php - Implementation of setUp().
- TaxonomyMenuCustomPathFunctionalTest::setUp in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuCustomPathFunctionalTest.php - Implementation of setUp().
- TaxonomyMenuFunctionalTest::setUp in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuFunctionalTest.php - Implementation of setUp().
- TaxonomyMenuFunctionalTest::testTaxonomyMenuTermsOverviewInterface in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuFunctionalTest.php - Re-order terms on the terms' overview page.
File
- lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuWebTestCase.php, line 75 - Definition of Drupal\taxonomy_menu\Tests\TaxonomyMenuWebTestCase.
Class
- TaxonomyMenuWebTestCase
- Abstract class for Taxonomy menu testing. All Taxonomy menu tests should extend this class.
Namespace
Drupal\taxonomy_menu\TestsCode
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]
->id(),
);
$terms[2]
->save();
$terms[3]->parent = array(
$terms[1]
->id(),
);
$terms[3]
->save();
$terms[4]->parent = array(
$terms[3]
->id(),
);
$terms[4]
->save();
$terms[5]->parent = array(
$terms[1]
->id(),
);
$terms[5]
->save();
$terms[7]->parent = array(
$terms[6]
->id(),
);
$terms[7]
->save();
return $terms;
}