function TermTest::testTermSaveOverrideSelector

Same name in other branches
  1. 10 core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testTermSaveOverrideSelector()
  2. 11.x core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testTermSaveOverrideSelector()

Test UI with override_selector TRUE.

File

core/modules/taxonomy/tests/src/Functional/TermTest.php, line 455

Class

TermTest
Tests load, save and delete for taxonomy terms.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testTermSaveOverrideSelector() {
    $this->config('taxonomy.settings')
        ->set('override_selector', TRUE)
        ->save();
    // Create a Term.
    $edit = [
        'name[0][value]' => $this->randomMachineName(12),
        'description[0][value]' => $this->randomMachineName(100),
    ];
    // Create the term to edit.
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/add');
    $this->submitForm($edit, 'Save');
    $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')
        ->loadByProperties([
        'name' => $edit['name[0][value]'],
    ]);
    $term = reset($terms);
    $this->assertNotNull($term, 'Term found in database.');
    // The term appears on the vocab list page.
    $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
        ->id() . '/overview');
    $this->assertSession()
        ->pageTextContains($term->getName());
}

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