Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.