function VocabularyUnitTest::testTaxonomyVocabularyLoadStaticReset

Ensure that the vocabulary static reset works correctly.

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php, line 75
Definition of Drupal\taxonomy\Tests\VocabularyUnitTest.

Class

VocabularyUnitTest
Tests for taxonomy vocabulary functions.

Namespace

Drupal\taxonomy\Tests

Code

function testTaxonomyVocabularyLoadStaticReset() {
  $original_vocabulary = taxonomy_vocabulary_load($this->vocabulary
    ->id());
  $this
    ->assertTrue(is_object($original_vocabulary), 'Vocabulary loaded successfully.');
  $this
    ->assertEqual($this->vocabulary->name, $original_vocabulary->name, 'Vocabulary loaded successfully.');

  // Change the name and description.
  $vocabulary = $original_vocabulary;
  $vocabulary->name = $this
    ->randomName();
  $vocabulary->description = $this
    ->randomName();
  $vocabulary
    ->save();

  // Load the vocabulary.
  $new_vocabulary = taxonomy_vocabulary_load($original_vocabulary
    ->id());
  $this
    ->assertEqual($new_vocabulary->name, $vocabulary->name);
  $this
    ->assertEqual($new_vocabulary->name, $vocabulary->name);

  // Delete the vocabulary.
  $this->vocabulary
    ->delete();
  $vocabularies = taxonomy_vocabulary_load_multiple();
  $this
    ->assertTrue(!isset($vocabularies[$this->vocabulary
    ->id()]), 'The vocabulary was deleted.');
}