Skip to content

Instantly share code, notes, and snippets.

@Shtangatopor
Created September 23, 2020 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shtangatopor/829b5bb5a11e3e33bc1cf10a5f788124 to your computer and use it in GitHub Desktop.
Save Shtangatopor/829b5bb5a11e3e33bc1cf10a5f788124 to your computer and use it in GitHub Desktop.
<?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