mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-29 04:55:02 +03:00
review user autorization method
This commit is contained in:
parent
c3a786cc32
commit
c530b41b5a
|
@ -54,7 +54,11 @@ Feature: LiveStreet standart features
|
||||||
|
|
||||||
|
|
||||||
5) При написании дополнительных тестов используются следующие правила:
|
5) При написании дополнительных тестов используются следующие правила:
|
||||||
а) Доступ из всех контектов з контексту MINK должен производится через функцию getMinkContext()
|
а) Доступ из базового контекcта к контексту MINK должен производится через функцию getMinkContext()
|
||||||
Пример получения доступа к сессии: $this->getMinkContext()->getSession()
|
Пример получения доступа к сессии: $this->getMinkContext()->getSession()
|
||||||
|
|
||||||
б) Получение доступа к базовому обьекту Engine производится посредством метода: $this->getEngine()
|
б) Получение доступа к базовому обьекту Engine производится посредством метода: $this->getEngine()
|
||||||
|
|
||||||
|
Прим: public function getEngine() {
|
||||||
|
return $this->getSubcontext('base')->getEngine();
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ use Behat\Behat\Context\ClosuredContextInterface,
|
||||||
Behat\Behat\Context\TranslatedContextInterface,
|
Behat\Behat\Context\TranslatedContextInterface,
|
||||||
Behat\Behat\Context\BehatContext,
|
Behat\Behat\Context\BehatContext,
|
||||||
Behat\MinkExtension\Context\MinkContext,
|
Behat\MinkExtension\Context\MinkContext,
|
||||||
|
Behat\Mink\Exception\ExpectationException,
|
||||||
Behat\Behat\Exception\PendingException;
|
Behat\Behat\Exception\PendingException;
|
||||||
use Behat\Gherkin\Node\PyStringNode,
|
use Behat\Gherkin\Node\PyStringNode,
|
||||||
Behat\Gherkin\Node\TableNode;
|
Behat\Gherkin\Node\TableNode;
|
||||||
|
@ -154,17 +155,18 @@ class BaseFeatureContext extends BehatContext
|
||||||
*/
|
*/
|
||||||
public function iWantToLoginAs($sUserLogin)
|
public function iWantToLoginAs($sUserLogin)
|
||||||
{
|
{
|
||||||
$moduleUser = $this->getEngine()->GetModuleObject('ModuleUser');
|
$oUser = $this->getEngine()->User_GetUserByLogin($sUserLogin);
|
||||||
|
|
||||||
$oUser = $moduleUser->GetUserByLogin($sUserLogin);
|
|
||||||
if (!$oUser) {
|
if (!$oUser) {
|
||||||
throw new ExpectationException( sprintf('User %s not found', $sUserLogin), $this->getMinkContext()->getSession());
|
throw new ExpectationException( sprintf('User %s not found', $sUserLogin), $this->getMinkContext()->getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleUser->Authorization($oUser, true);
|
$this->getEngine()->User_Authorization($oUser, true);
|
||||||
$sSessionKey = $moduleUser->GetSessionByUserId($oUser->getId())->getKey();
|
$oSession = $this->getEngine()->User_GetSessionByUserId($oUser->getId());
|
||||||
|
if (!$oSession) {
|
||||||
|
throw new ExpectationException( 'Session non created', $this->getMinkContext()->getSession());
|
||||||
|
}
|
||||||
|
|
||||||
$this->getMinkContext()->getSession()->getDriver()->setCookie("key", $sSessionKey);
|
$this->getMinkContext()->getSession()->getDriver()->setCookie("key", $oSession->getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,8 +14,7 @@ class FeatureContext extends MinkContext
|
||||||
$this->useContext('base', new BaseFeatureContext($parameters));
|
$this->useContext('base', new BaseFeatureContext($parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMinkContext()
|
public function getEngine() {
|
||||||
{
|
return $this->getSubcontext('base')->getEngine();
|
||||||
return $this->getMainContext();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue