public function TermParentsTest::testEditingParentsWithDisabledFormElement in Drupal 10
Same name and namespace in other branches
- 8 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::testEditingParentsWithDisabledFormElement()
- 9 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 162
Class
- TermParentsTest
- Tests managing taxonomy parents through the user interface.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testEditingParentsWithDisabledFormElement() {
// 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);
}