-
-
Save Shtangatopor/829b5bb5a11e3e33bc1cf10a5f788124 to your computer and use it in GitHub Desktop.
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 | |
namespace App\Tests\Helper; | |
// here you can define custom actions | |
// all public methods declared in helper class will be available in $I | |
use App\Tests\AcceptanceTester; | |
use App\Tests\ApiTester; | |
class Api extends \Codeception\Module | |
{ | |
/** | |
* @var \App\Tests\ApiTester; | |
*/ | |
protected $apiTester; | |
protected $acceptanceTester; | |
public function __construct(ApiTester $api, AcceptanceTester $I) | |
{ | |
$this->apiTester = $api; | |
$this->acceptanceTester = $I; | |
} | |
public function authorization($username, $password) | |
{ | |
$api = $this->apiTester; | |
$this->$username = $username; | |
$this->$password = $password; | |
$api->amOnPage('/login'); | |
$csrf_token = $api->grabAttributeFrom('.login-form > input:nth-child(5)', 'value'); | |
$api->sendPOST('/login', [ | |
'username' => $username, | |
'password' => $password, | |
'_remember_me' => 'on', | |
'_csrf_token' => $csrf_token | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment