function TermParentsTest::testEditingParents

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParents()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParents()
  3. 10 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParents()

Tests editing the parents of existing terms.

File

core/modules/taxonomy/tests/src/Functional/TermParentsTest.php, line 138

Class

TermParentsTest
Tests managing taxonomy parents through the user interface.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testEditingParents() : void {
    $terms = $this->doTestEditingSingleParent();
    $term_5 = array_pop($terms);
    $term_4 = array_pop($terms);
    // Create a term with multiple parents.
    $term_6 = $this->createTerm('Test term 6', [
        // Term 5 comes before term 4 in the user interface, so add the parents in
        // the matching order.
$term_5->id(),
        $term_4->id(),
    ]);
    $this->drupalGet($term_6->toUrl('edit-form'));
    $this->assertParentOption('<root>');
    $this->assertParentOption('Test term 1');
    $this->assertParentOption('-Test term 3');
    $this->assertParentOption('--Test term 5', TRUE);
    $this->assertParentOption('Test term 2');
    $this->assertParentOption('-Test term 4', TRUE);
    $this->submitForm([], 'Save');
    $this->assertParentsUnchanged($term_6);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.