You are here

public function TermKernelTest::testTermDelete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/TermKernelTest.php \Drupal\taxonomy\Tests\TermKernelTest::testTermDelete()

Deleting terms should also remove related vocabulary. Deleting an invalid term should silently fail.

File

core/modules/taxonomy/src/Tests/TermKernelTest.php, line 40
Contains \Drupal\taxonomy\Tests\TermKernelTest.

Class

TermKernelTest
Kernel tests for taxonomy term functions.

Namespace

Drupal\taxonomy\Tests

Code

public function testTermDelete() {
  $vocabulary = $this
    ->createVocabulary();
  $valid_term = $this
    ->createTerm($vocabulary);

  // Delete a valid term.
  $valid_term
    ->delete();
  $terms = entity_load_multiple_by_properties('taxonomy_term', array(
    'vid' => $vocabulary
      ->id(),
  ));
  $this
    ->assertTrue(empty($terms), 'Vocabulary is empty after deletion');

  // Delete an invalid term. Should not throw any notices.
  entity_delete_multiple('taxonomy_term', array(
    42,
  ));
}