You are here

function ServicesResourceUsertests::testUpdateUser in Services 6.3

Same name and namespace in other branches
  1. 7.3 tests/functional/ServicesResourceUserTests.test \ServicesResourceUsertests::testUpdateUser()

Test update method.

Create user, update email.

File

tests/functional/ServicesResourceUserTests.test, line 257

Class

ServicesResourceUsertests
Run test cases for the endpoint with no authentication turned on.

Code

function testUpdateUser() {

  // Create user.
  $account = $this
    ->drupalCreateUser();

  // Update mail of the user. Note: roles is required attribute as update
  // method does drupal_execute of user_profile_form form.
  $updated_account = array(
    'uid' => $account->uid,
    'name' => $account->name,
    'roles' => $account->roles,
    'mail' => $this
      ->randomName() . '@example.com',
  );
  $response = $this
    ->servicesPut($this->endpoint->path . '/user/' . $account->uid, $updated_account);
  $user_load = user_load($account->uid);
  $this
    ->assertEqual($updated_account['mail'], $user_load->mail, t('User details have been updated successfully'), 'UserResource: Update');
}