function UserTest::assertRpcLogin

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/UserTest.php \Drupal\Tests\jsonapi\Functional\UserTest::assertRpcLogin()
  2. 8.9.x core/modules/jsonapi/tests/src/Functional/UserTest.php \Drupal\Tests\jsonapi\Functional\UserTest::assertRpcLogin()
  3. 10 core/modules/jsonapi/tests/src/Functional/UserTest.php \Drupal\Tests\jsonapi\Functional\UserTest::assertRpcLogin()

Verifies that logging in with the given username and password works.

@internal

Parameters

string $username: The username to log in with.

string $password: The password to log in with.

1 call to UserTest::assertRpcLogin()
UserTest::testPatchDxForSecuritySensitiveBaseFields in core/modules/jsonapi/tests/src/Functional/UserTest.php
Tests PATCHing security-sensitive base fields of the logged in account.

File

core/modules/jsonapi/tests/src/Functional/UserTest.php, line 324

Class

UserTest
JSON:API integration test for the "User" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function assertRpcLogin(string $username, string $password) : void {
    $request_body = [
        'name' => $username,
        'pass' => $password,
    ];
    $request_options = [
        RequestOptions::HEADERS => [],
        RequestOptions::BODY => Json::encode($request_body),
    ];
    $response = $this->request('POST', Url::fromRoute('user.login.http')->setRouteParameter('_format', 'json'), $request_options);
    $this->assertSame(200, $response->getStatusCode());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.