public function ServicesParserTests::testJSONCall in Services 6.3
Same name and namespace in other branches
- 7.3 tests/functional/ServicesParserTests.test \ServicesParserTests::testJSONCall()
Do JSON call. Ensure it is parsed properly.
File
- tests/
functional/ ServicesParserTests.test, line 109 - Call the endpoint tests when no authentication is being used.
Class
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, t('User successfully logged in via JSON call.'), 'JSON Call: Login');
}