1 taxonomy.test TaxonomyTermTestCase::testTermMultipleParentsInterface()

Test saving a term with multiple parents through the UI.


core/modules/taxonomy/tests/taxonomy.test, line 823
Tests for taxonomy.module.


Tests for taxonomy term functions.


function testTermMultipleParentsInterface() {
  // Add a new term to the vocabulary so that we can have multiple parents.
  $parent = $this->createTerm($this->vocabulary);

  // Add a new term with multiple parents.
  $edit = array(
    'name' => $this->randomName(12),
    'description[value]' => $this->randomName(100),
    'parent[]' => array(0, $parent->tid),
  // Save the new term.
  $this->backdropPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));

  // Check that the term was successfully created.
  $terms = taxonomy_term_load_multiple_by_name($edit['name']);
  $term = reset($terms);
  $this->assertNotNull($term, 'Term found in database.');
  $this->assertEqual($edit['name'], $term->name, 'Term name was successfully saved.');
  $this->assertEqual($edit['description[value]'], $term->description, 'Term description was successfully saved.');
  // Check that the parent tid is still there. The other parent (<root>) is
  // not added by taxonomy_term_load_parents().
  $parents = taxonomy_term_load_parents($term->tid);
  $parent = reset($parents);
  $this->assertEqual($edit['parent[]'][1], $parent->tid, 'Term parents were successfully saved.');