public function EntityCrudHookTestCase::testTaxonomyVocabularyHooks

Tests hook invocations for CRUD operations on taxonomy vocabularies.

File

drupal/modules/simpletest/tests/entity_crud_hook_test.test, line 259
CRUD hook tests for the Entity CRUD API.

Class

EntityCrudHookTestCase
Tests invocation of hooks when performing an action.

Code

public function testTaxonomyVocabularyHooks() {
  $vocabulary = (object) array(
    'name' => 'Test vocabulary',
    'machine_name' => 'test',
    'description' => NULL,
    'module' => 'entity_crud_hook_test',
  );
  $_SESSION['entity_crud_hook_test'] = array();
  taxonomy_vocabulary_save($vocabulary);
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_presave called');
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_insert called');
  $_SESSION['entity_crud_hook_test'] = array();
  $vocabulary = taxonomy_vocabulary_load($vocabulary->vid);
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_load called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_load called');
  $_SESSION['entity_crud_hook_test'] = array();
  $vocabulary->name = 'New name';
  taxonomy_vocabulary_save($vocabulary);
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_presave called');
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_update called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_update called');
  $_SESSION['entity_crud_hook_test'] = array();
  taxonomy_vocabulary_delete($vocabulary->vid);
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary');
  $this
    ->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_delete called');
}