This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthCest | |
{ | |
// tests | |
public function validCredentials(ApiTester $I) | |
{ | |
$I->wantTo('Generate access token'); | |
$email = uniqid('email-') . '@gmail.com'; | |
$password = uniqid('password-'); | |
// create user in database | |
$userId = $I->createUser([ | |
'email' => $email, | |
'password' => $password | |
]); | |
// generate access token via API | |
$I->haveHttpHeader('Content-Type', 'application/json'); | |
$I->sendPOST('/api/v1/auth/authenticate', ['email' => $email, 'password' => $password]); | |
// validate response | |
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); | |
$I->seeResponseIsJson(); | |
$I->seeResponseJsonMatchesJsonPath('$.token'); | |
$I->seeResponseJsonMatchesJsonPath('$.userId'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment