You are here

function ServicesResourceUsertests::testUserLogout in Services 6.3

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

Test logout method.

File

tests/functional/ServicesResourceUserTests.test, line 359

Class

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

Code

function testUserLogout() {

  // Logout via REST call.
  $response = $this
    ->servicesPost($this->endpoint->path . '/user/logout');

  // Try logout second time.
  $this
    ->drupalLogout();
  $this
    ->assertText(t('You are not authorized to access this page'), t('User logout successfully.'), 'UserResource: Logout');

  // Login again.
  $this
    ->drupalLogin($this->privileged_user);

  // Logout via REST call.
  $response = $this
    ->servicesPost($this->endpoint->path . '/user/logout');

  // Try to logout second time via REST call.
  $response = $this
    ->servicesPost($this->endpoint->path . '/user/logout');
  $this
    ->assertTrue(strpos($response['status'], 'User is not logged in'), t('User cannot logout when is anonymous'), 'UserResource: Logout');
}