function TermKernelTest::testTermDelete

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php \Drupal\Tests\taxonomy\Kernel\TermKernelTest::testTermDelete()
  2. 10 core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php \Drupal\Tests\taxonomy\Kernel\TermKernelTest::testTermDelete()
  3. 11.x core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php \Drupal\Tests\taxonomy\Kernel\TermKernelTest::testTermDelete()

Tests that a deleted term is no longer in the vocabulary.

File

core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php, line 35

Class

TermKernelTest
Kernel tests for taxonomy term functions.

Namespace

Drupal\Tests\taxonomy\Kernel

Code

public function testTermDelete() {
    $vocabulary = $this->createVocabulary();
    $valid_term = $this->createTerm($vocabulary);
    // Delete a valid term.
    $valid_term->delete();
    $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')
        ->loadByProperties([
        'vid' => $vocabulary->id(),
    ]);
    $this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
}

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