You are here

protected function TermParentsTest::submitAddTermForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::submitAddTermForm()
  2. 9 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.

File

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

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;
}