You are here

public function TermParentsTest::testEditingParents in Drupal 9

Same name and namespace in other branches
  1. 8 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 136

Class

TermParentsTest
Tests managing taxonomy parents through the user interface.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testEditingParents() {
  $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);
}