You are here

public function ServicesParserTests::testJSONCall in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesParserTests.test \ServicesParserTests::testJSONCall()

Do JSON call. Ensure it is parsed properly.

File

tests/functional/ServicesParserTests.test, line 103
Call the endpoint tests when no authentication is being used.

Class

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

Code

public function testJSONCall() {
  $account = $this
    ->drupalCreateUser();

  // Logout first.
  $this
    ->drupalLogout();

  // Do JSON call to login.
  $response = $this
    ->servicesPost($this->endpoint->path . '/user/login', array(
    'username' => $account->name,
    'password' => $account->pass_raw,
  ), array(), 'json');
  $body = $response['body'];
  $proper_answer = isset($body->sessid) && isset($body->user) && $body->user->name == $account->name;
  $this
    ->assertTrue($proper_answer, 'User successfully logged in via JSON call.', 'JSON Call: Login');
}