You are here

function ServicesXMLRPCTestCase::testUserLogin in Services 7.3

Test user login.

File

tests/functional/ServicesXMLRPCTests.test, line 50

Class

ServicesXMLRPCTestCase

Code

function testUserLogin() {

  // Create user.
  $user = $this
    ->drupalCreateUser(array(
    'access user profiles',
  ));
  $args = array(
    'username' => $user->name,
    'password' => $user->pass_raw,
  );
  $result = $this
    ->servicesXMLRPC('user.login', $args);
  $this
    ->assertEqual($result['body']['user']['uid'], $user->uid, format_string('User %user logged in successfully.', array(
    '%user' => $user->name,
  )), 'XMLRPC: UserLogin');
  $this->sessid = $result['body']['sessid'];
  $this->session_name = $result['body']['session_name'];

  // Call index method as logged in user.
  $args = array(
    'page' => 0,
    'fields' => '*',
    'parameters' => array(),
  );
  $result = $this
    ->servicesXMLRPC('user.index', $args);

  // There should be three users available: anonymous, admin and newly created.
  $this
    ->assertTrue(count($result['body']) == 3, 'Users listed properly.', 'XMLRPC: UserLogin');
}