function RestfulAuthenticationTestCase::testSwitchUser in RESTful 7
Test switching the user in an API call.
File
- tests/
RestfulAuthenticationTestCase.test, line 127 - Contains RestfulAuthenticationTestCase.
Class
- RestfulAuthenticationTestCase
- @file Contains RestfulAuthenticationTestCase.
Code
function testSwitchUser() {
global $user;
// We need to hijack the global user object in order to force it to be an
// anonymous user.
$user = drupal_anonymous_user();
$user1 = $this
->drupalCreateUser();
$handler = restful_get_restful_handler('articles');
$handler
->setAccount($user1);
$handler
->get();
$this
->assertEqual($user->uid, 0, 'Global user is the correct one after an API call that switches the user.');
}