You are here

protected function TermParentsTest::submitAddTermForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/TermParentsTest.php \Drupal\Tests\taxonomy\Functional\TermParentsTest::submitAddTermForm()
  2. 10 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 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
    ->drupalPostForm(NULL, [], 'Save');
  $result = $this->termStorage
    ->getQuery()
    ->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;
}