function UserResourceTestBase::assertRpcLogin

Same name in other branches
  1. 9 core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php \Drupal\Tests\user\Functional\Rest\UserResourceTestBase::assertRpcLogin()
  2. 8.9.x core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php \Drupal\Tests\user\Functional\Rest\UserResourceTestBase::assertRpcLogin()
  3. 10 core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php \Drupal\Tests\user\Functional\Rest\UserResourceTestBase::assertRpcLogin()

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

Parameters

string $username: The username to log in with.

string $password: The password to log in with.

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

File

core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php, line 262

Class

UserResourceTestBase

Namespace

Drupal\Tests\user\Functional\Rest

Code

protected function assertRpcLogin($username, $password) {
    $request_body = [
        'name' => $username,
        'pass' => $password,
    ];
    $request_options = [
        RequestOptions::HEADERS => [],
        RequestOptions::BODY => $this->serializer
            ->encode($request_body, 'json'),
    ];
    $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.