1

I wanted to automate the functional codeception testing in yii2,I am able to test the login API using the following code

use tests\codeception\backend\FunctionalTester;
$I = new FunctionalTester($scenario);
$I->wantTo('Check when authenticated');
$I->sendPOST('/login', ['password' => '11111111', 'email'=>'[email protected]']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"result"');
$I->seeResponseContains('"message"');
$I->haveHttpHeader('Accept','application/json');
$I->seeResponseContains('"message":"OK"');

In Login API I return the auth_token which can be used for further processing,So Where do I save the result of login API and use it for testing the further API's

2

1 Answer 1

1

We can store the response using the following function.and check it further for API's

$check = $I->grabResponse();
$check = json_decode($check,true);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.