function TermParentsTest::doTestEditingSingleParent
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::doTestEditingSingleParent()
- 8.9.x core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::doTestEditingSingleParent()
- 10 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::doTestEditingSingleParent()
Performs tests that edit terms with a single parent.
Return value
\Drupal\taxonomy\TermInterface[] A list of terms created for testing.
2 calls to TermParentsTest::doTestEditingSingleParent()
- TermParentsTest::testEditingParents in core/
modules/ taxonomy/ tests/ src/ Functional/ TermParentsTest.php - Tests editing the parents of existing terms.
- TermParentsTest::testEditingParentsWithDisabledFormElement in core/
modules/ taxonomy/ tests/ src/ Functional/ TermParentsTest.php - Tests specifying parents when creating terms and a disabled parent form.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermParentsTest.php, line 198
Class
- TermParentsTest
- Tests managing taxonomy parents through the user interface.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
protected function doTestEditingSingleParent() : array {
$terms = [];
// Create two terms without any parents.
$term_1 = $this->createTerm('Test term 1');
$this->drupalGet($term_1->toUrl('edit-form'));
$this->assertParentOption('<root>', TRUE);
$this->submitForm([], 'Save');
$this->assertParentsUnchanged($term_1);
$terms[] = $term_1;
$term_2 = $this->createTerm('Test term 2');
$this->drupalGet($term_2->toUrl('edit-form'));
$this->assertParentOption('<root>', TRUE);
$this->assertParentOption('Test term 1');
$this->submitForm([], 'Save');
$this->assertParentsUnchanged($term_2);
$terms[] = $term_2;
// Create two terms with the previously created terms as parents,
// respectively.
$term_3 = $this->createTerm('Test term 3', [
$term_1->id(),
]);
$this->drupalGet($term_3->toUrl('edit-form'));
$this->assertParentOption('<root>');
$this->assertParentOption('Test term 1', TRUE);
$this->assertParentOption('Test term 2');
$this->submitForm([], 'Save');
$this->assertParentsUnchanged($term_3);
$terms[] = $term_3;
$term_4 = $this->createTerm('Test term 4', [
$term_2->id(),
]);
$this->drupalGet($term_4->toUrl('edit-form'));
$this->assertParentOption('<root>');
$this->assertParentOption('Test term 1');
$this->assertParentOption('-Test term 3');
$this->assertParentOption('Test term 2', TRUE);
$this->submitForm([], 'Save');
$this->assertParentsUnchanged($term_4);
$terms[] = $term_4;
// Create a term with term 3 as parent.
$term_5 = $this->createTerm('Test term 5', [
$term_3->id(),
]);
$this->drupalGet($term_5->toUrl('edit-form'));
$this->assertParentOption('<root>');
$this->assertParentOption('Test term 1');
$this->assertParentOption('-Test term 3', TRUE);
$this->assertParentOption('Test term 2');
$this->assertParentOption('-Test term 4');
$this->submitForm([], 'Save');
$this->assertParentsUnchanged($term_5);
$terms[] = $term_5;
return $terms;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.