function TermParentsTest::assertParentOption

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

Asserts that an option in the parent form element of terms exists.

@internal

Parameters

string $option: The label of the parent option.

bool $selected: (optional) Whether or not the option should be selected. Defaults to FALSE.

3 calls to TermParentsTest::assertParentOption()
TermParentsTest::doTestEditingSingleParent in core/modules/taxonomy/tests/src/Functional/TermParentsTest.php
Performs tests that edit terms with a single parent.
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 288

Class

TermParentsTest
Tests managing taxonomy parents through the user interface.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function assertParentOption(string $option, bool $selected = FALSE) : void {
    $option = $this->assertSession()
        ->optionExists('Parent terms', $option);
    if ($selected) {
        $this->assertTrue($option->hasAttribute('selected'));
    }
    else {
        $this->assertFalse($option->hasAttribute('selected'));
    }
}

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