function ServicesResourceUsertests::testUserLogout in Services 7.3
Same name and namespace in other branches
- 6.3 tests/functional/ServicesResourceUserTests.test \ServicesResourceUsertests::testUserLogout()
Test logout method.
File
- tests/
functional/ ServicesResourceUserTests.test, line 624 - Call the endpoint tests when no authentication is being used.
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
->drupalGet('user/logout');
$this
->assertText('You are not authorized to access this page', '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'), 'User cannot logout when is anonymous', 'UserResource: Logout');
}