diff --git a/tests/codeception/api/_support/FunctionalTester.php b/tests/codeception/api/_support/FunctionalTester.php index cc985c6..a06b732 100644 --- a/tests/codeception/api/_support/FunctionalTester.php +++ b/tests/codeception/api/_support/FunctionalTester.php @@ -1,9 +1,10 @@ login('Admin', 'password_0'); + $form = new LoginForm(); + if ($login === null && $password === null) { + $form->login = 'Admin'; + $form->password = 'password_0'; } elseif ($login !== null && $password !== null) { - $route->login($login, $password); + $form->login = $login; + $form->password = $password; } else { throw new InvalidArgumentException('login and password should be presented both.'); } - $this->canSeeResponseIsJson(); - $this->canSeeAuthCredentials(false); - $jwt = $this->grabDataFromResponseByJsonPath('$.access_token')[0]; - $this->amBearerAuthenticated($jwt); + $result = $form->login(); + $this->assertInstanceOf(LoginResult::class, $result); + if ($result !== false) { + $this->amBearerAuthenticated($result->getJwt()); + } } public function notLoggedIn() {