function TermParentsTest::submitAddTermForm

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

Creates a term through the user interface and returns it.

Parameters

string $name: The name of the term to create.

Return value

\Drupal\taxonomy\TermInterface The newly created taxonomy term.

1 call to TermParentsTest::submitAddTermForm()
TermParentsTest::testAddWithParents in core/modules/taxonomy/tests/src/Functional/TermParentsTest.php
Tests specifying parents when creating terms.

File

core/modules/taxonomy/tests/src/Functional/TermParentsTest.php, line 119

Class

TermParentsTest
Tests managing taxonomy parents through the user interface.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function submitAddTermForm($name) {
    $this->getSession()
        ->getPage()
        ->fillField('Name', $name);
    $this->submitForm([], 'Save');
    $result = $this->termStorage
        ->getQuery()
        ->accessCheck(FALSE)
        ->condition('name', $name)
        ->execute();
    
    /** @var \Drupal\taxonomy\TermInterface $term_1 */
    $term_1 = $this->termStorage
        ->load(reset($result));
    $this->assertInstanceOf(TermInterface::class, $term_1);
    return $term_1;
}

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