EntityCrudHookTestCase::testTaxonomyVocabularyHooks

7 entity_crud_hook_test.test public EntityCrudHookTestCase::testTaxonomyVocabularyHooks()
8 entity_crud_hook_test.test public EntityCrudHookTestCase::testTaxonomyVocabularyHooks()

Test hook invocations for CRUD operations on taxonomy vocabularies.

File

modules/simpletest/tests/entity_crud_hook_test.test, line 253

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');
}
Login or register to post comments