login = 'Admin'; $form->password = 'password_0'; } elseif ($login !== null && $password !== null) { $form->login = $login; $form->password = $password; } else { throw new InvalidArgumentException('login and password should be presented both.'); } $result = $form->login(); $this->assertInstanceOf(LoginResult::class, $result); if ($result !== false) { $this->amBearerAuthenticated($result->getJwt()); } } public function notLoggedIn() { $this->haveHttpHeader('Authorization', null); } public function canSeeAuthCredentials($expectRefresh = false) { $this->canSeeResponseJsonMatchesJsonPath('$.access_token'); $this->canSeeResponseJsonMatchesJsonPath('$.expires_in'); if ($expectRefresh) { $this->canSeeResponseJsonMatchesJsonPath('$.refresh_token'); } else { $this->cantSeeResponseJsonMatchesJsonPath('$.refresh_token'); } } }