function TermParentsTest::testEditingParentsWithDisabledFormElement
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParentsWithDisabledFormElement()
- 8.9.x core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParentsWithDisabledFormElement()
- 11.x core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParentsWithDisabledFormElement()
Tests specifying parents when creating terms and a disabled parent form.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermParentsTest.php, line 164
Class
- TermParentsTest
- Tests managing taxonomy parents through the user interface.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testEditingParentsWithDisabledFormElement() : void {
// Disable the parent form element.
$this->state
->set('taxonomy_test.disable_parent_form_element', TRUE);
$this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add");
$this->assertSession()
->fieldDisabled('Parent terms');
$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', [
// When the parent form element is disabled, its default value is used as
// the value which gets populated in ascending order of term IDs.
$term_4->id(),
$term_5->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.