function HierarchicalTermFormatterTestCase::createHierarchy in Hierarchical Term Formatter 7
Create many terms in a hierarchy that allows testing the formatter display.
1 call to HierarchicalTermFormatterTestCase::createHierarchy()
- HierarchicalTermFormatterTestCase::setUp in ./
hierarchical_term_formatter.test - Sets up a Drupal site for running functional and integration tests.
File
- ./
hierarchical_term_formatter.test, line 62 - Tests for Field Multiple Limit, based on examples from field.test
Class
- HierarchicalTermFormatterTestCase
- Test the field formatter settings work.
Code
function createHierarchy() {
$root_term = $this
->createTerm();
$this->terms = array();
$this->terms['terms'][] = $root_term;
$this->terms['tids'][] = $root_term->tid;
$this->terms['names'][] = $root_term->name;
// Add 5 more root-level terms.
for ($i = 0; $i < 5; $i++) {
$term = $this
->createTerm();
$this->terms['terms'][] = $term;
$this->terms['tids'][] = $term->tid;
$this->terms['names'][] = $term->name;
}
// Add 5 child terms to the root term and second term.
for ($i = 0; $i < 5; $i++) {
$term = $this
->createTerm(array(
$root_term->tid,
$root_term->tid + 1,
));
$this->terms['terms'][] = $term;
$this->terms['tids'][] = $term->tid;
$this->terms['names'][] = $term->name;
}
// Add 3 child terms to the 2nd child term.
for ($i = 0; $i < 3; $i++) {
$term = $this
->createTerm($root_term->tid + 6);
$this->terms['terms'][] = $term;
$this->terms['tids'][] = $term->tid;
$this->terms['names'][] = $term->name;
}
// Add 3 child terms to the 3rd child term.
for ($i = 0; $i < 3; $i++) {
$term = $this
->createTerm($root_term->tid + 7);
$this->terms['terms'][] = $term;
$this->terms['tids'][] = $term->tid;
$this->terms['names'][] = $term->name;
}
// Add 5 more root-level terms.
for ($i = 0; $i < 5; $i++) {
$term = $this
->createTerm();
$this->terms['terms'][] = $term;
$this->terms['tids'][] = $term->tid;
$this->terms['names'][] = $term->name;
}
}