function TermUnitTest::testTermDelete

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermUnitTest.php, line 23
Definition of Drupal\taxonomy\Tests\TermUnitTest.

Class

TermUnitTest
Unit tests for taxonomy term functions.

Namespace

Drupal\taxonomy\Tests

Code

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,
  ));
}