2016-05-10 17:37:32 +05:30
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api;
|
|
|
|
|
2016-05-16 13:51:12 +05:30
|
|
|
use Codeception\Actor;
|
|
|
|
use InvalidArgumentException;
|
2016-05-11 01:55:04 +05:30
|
|
|
use tests\codeception\api\_pages\AuthenticationRoute;
|
2016-05-10 17:37:32 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited Methods
|
|
|
|
* @method void wantToTest($text)
|
|
|
|
* @method void wantTo($text)
|
|
|
|
* @method void execute($callable)
|
|
|
|
* @method void expectTo($prediction)
|
|
|
|
* @method void expect($prediction)
|
|
|
|
* @method void amGoingTo($argumentation)
|
|
|
|
* @method void am($role)
|
|
|
|
* @method void lookForwardTo($achieveValue)
|
|
|
|
* @method void comment($description)
|
|
|
|
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
|
|
|
*
|
|
|
|
* @SuppressWarnings(PHPMD)
|
|
|
|
*/
|
2016-05-16 13:51:12 +05:30
|
|
|
class FunctionalTester extends Actor {
|
2016-05-10 17:37:32 +05:30
|
|
|
use _generated\FunctionalTesterActions;
|
|
|
|
|
2016-05-16 13:51:12 +05:30
|
|
|
public function loggedInAsActiveAccount($login = null, $password = null) {
|
|
|
|
$route = new AuthenticationRoute($this);
|
|
|
|
if ($login === null) {
|
|
|
|
$route->login('Admin', 'password_0');
|
|
|
|
} elseif ($login !== null && $password !== null) {
|
|
|
|
$route->login($login, $password);
|
|
|
|
} else {
|
|
|
|
throw new InvalidArgumentException('login and password should be presented both.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->canSeeResponseIsJson();
|
|
|
|
$this->canSeeResponseJsonMatchesJsonPath('$.jwt');
|
|
|
|
$jwt = $this->grabDataFromResponseByJsonPath('$.jwt')[0];
|
|
|
|
$this->amBearerAuthenticated($jwt);
|
2016-05-10 17:37:32 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
public function notLoggedIn() {
|
|
|
|
$this->haveHttpHeader('Authorization', null);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|