Last active
May 8, 2019 06:13
-
-
Save fityanos/f31df4ed15443e20db1c59acf9b9e77c to your computer and use it in GitHub Desktop.
exampleClass
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
<?php | |
use \Codeception\Util\HttpCode as responseValidate; | |
/** | |
* Class classNameCest | |
* | |
* @group apiLevelOne | |
* @group apiLevelTwo | |
* | |
*/ | |
class classNameCest | |
{ | |
/** | |
* @param ApiGuy $I | |
* @throws Exception | |
*/ | |
protected function GenerateToken(ApiGuy $I) | |
{ | |
$I->haveHttpHeader('Accept', 'application/json'); | |
$I->haveHttpHeader('Content-Type', 'application/json'); | |
$I->sendPOST('/user/auth/token', [ | |
'username' => '$userName', | |
'password' => '$password' | |
]); | |
/** Assertions for status code && JSON body */ | |
$I->seeResponseCodeIs(responseValidate::OK); // 200 | |
$I->seeResponseIsJson(); | |
$I->seeResponseContains('access_token'); | |
/**fetch token in $token*/ | |
$token = $I->grabDataFromResponseByJsonPath('$.access_token'); | |
$this->token = $token; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment