Tests hook invocations for CRUD operations on taxonomy terms.
public function testTaxonomyTermHooks() {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Test vocabulary',
'machine_name' => 'test',
'langcode' => LANGUAGE_NOT_SPECIFIED,
'description' => NULL,
'module' => 'entity_crud_hook_test',
));
taxonomy_vocabulary_save($vocabulary);
$term = entity_create('taxonomy_term', array(
'vid' => $vocabulary->vid,
'name' => 'Test term',
'langcode' => LANGUAGE_NOT_SPECIFIED,
'description' => NULL,
'format' => 1,
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_save($term);
$this
->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_insert called',
'entity_crud_hook_test_entity_insert called for type taxonomy_term',
));
$_SESSION['entity_crud_hook_test'] = array();
$term = taxonomy_term_load($term->tid);
$this
->assertHookMessageOrder(array(
'entity_crud_hook_test_entity_load called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_load called',
));
$_SESSION['entity_crud_hook_test'] = array();
$term->name = 'New name';
taxonomy_term_save($term);
$this
->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_update called',
'entity_crud_hook_test_entity_update called for type taxonomy_term',
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_delete($term->tid);
$this
->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_predelete called',
'entity_crud_hook_test_entity_predelete called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_delete called',
'entity_crud_hook_test_entity_delete called for type taxonomy_term',
));
}