You are here

public function TermKernelTest::testTermDelete in Drupal 9

Same name and namespace in other branches
  1. 8 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');
}