function EntityCrudHookTestCase::testUserHooks
Tests hook invocations for CRUD operations on users.
File
-
modules/
simpletest/ tests/ entity_crud_hook_test.test, line 299
Class
- EntityCrudHookTestCase
- Tests invocation of hooks when performing an action.
Code
public function testUserHooks() {
$edit = array(
'name' => 'Test user',
'mail' => 'test@example.com',
'created' => REQUEST_TIME,
'status' => 1,
'language' => 'en',
);
$account = (object) $edit;
$_SESSION['entity_crud_hook_test'] = array();
$account = user_save($account, $edit);
$this->assertHookMessage('entity_crud_hook_test_entity_presave called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_presave called');
$this->assertHookMessage('entity_crud_hook_test_entity_insert called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_insert called');
$_SESSION['entity_crud_hook_test'] = array();
$account = user_load($account->uid);
$this->assertHookMessage('entity_crud_hook_test_entity_load called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_load called');
$_SESSION['entity_crud_hook_test'] = array();
$edit['name'] = 'New name';
$account = user_save($account, $edit);
$this->assertHookMessage('entity_crud_hook_test_entity_presave called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_presave called');
$this->assertHookMessage('entity_crud_hook_test_entity_update called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_update called');
$_SESSION['entity_crud_hook_test'] = array();
user_delete($account->uid);
$this->assertHookMessage('entity_crud_hook_test_entity_delete called for type user');
$this->assertHookMessage('entity_crud_hook_test_user_delete called');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.