rename module methods in extended OXID classes to prevent conflicts with other modules, move totp check to _afterLogin for webauthn module compatibility

This commit is contained in:
Daniel Seifert 2022-11-09 12:03:16 +01:00
parent f110142474
commit c80b5f626f
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
15 changed files with 152 additions and 156 deletions

View File

@ -13,7 +13,7 @@ class d3force_2fa extends d3user_totp
{ {
$this->addTplParam('force2FA', true); $this->addTplParam('force2FA', true);
$userID = $this->d3GetSessionObject()->getVariable("auth"); $userID = $this->d3TotpGetSessionObject()->getVariable("auth");
$this->_sEditObjectId = $userID; $this->_sEditObjectId = $userID;
return parent::render(); return parent::render();
@ -22,7 +22,7 @@ class d3force_2fa extends d3user_totp
protected function _authorize() protected function _authorize()
{ {
$userID = $this->d3GetSessionObject()->getVariable("auth"); $userID = $this->d3TotpGetSessionObject()->getVariable("auth");
return ($this->d3IsAdminForce2FA() && !empty($userID)); return ($this->d3IsAdminForce2FA() && !empty($userID));
} }
@ -30,7 +30,7 @@ class d3force_2fa extends d3user_totp
/** /**
* @return Session * @return Session
*/ */
private function d3GetSessionObject() private function d3TotpGetSessionObject()
{ {
return Registry::getSession(); return Registry::getSession();
} }

View File

@ -57,7 +57,7 @@ class d3backupcode extends BaseModel
public function d3EncodeBC($code, $sUserId) public function d3EncodeBC($code, $sUserId)
{ {
$oDb = DatabaseProvider::getDb(); $oDb = DatabaseProvider::getDb();
$oUser = $this->d3GetUserObject(); $oUser = $this->d3TotpGetUserObject();
$oUser->load($sUserId); $oUser->load($sUserId);
$salt = $oUser->getFieldData('oxpasssalt'); $salt = $oUser->getFieldData('oxpasssalt');
$sSelect = "SELECT BINARY MD5( CONCAT( " . $oDb->quote($code) . ", UNHEX( ".$oDb->quote($salt)." ) ) )"; $sSelect = "SELECT BINARY MD5( CONCAT( " . $oDb->quote($code) . ", UNHEX( ".$oDb->quote($salt)." ) ) )";
@ -83,7 +83,7 @@ class d3backupcode extends BaseModel
/** /**
* @return User * @return User
*/ */
public function d3GetUserObject() public function d3TotpGetUserObject()
{ {
return oxNew(User::class); return oxNew(User::class);
} }

View File

@ -11,7 +11,7 @@
<form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login"> <form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login">
[{$oViewConf->getHiddenSid()}] [{$oViewConf->getHiddenSid()}]
<input type="hidden" name="fnc" value="d3TotpCheckTotpLogin"> <input type="hidden" name="fnc" value="checkTotplogin">
<input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]"> <input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]">
[{$navFormParams}] [{$navFormParams}]
@ -34,7 +34,7 @@
<form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login"> <form action="[{$oViewConf->getSelfActionLink()}]" method="post" name="login" id="login">
[{$oViewConf->getHiddenSid()}] [{$oViewConf->getHiddenSid()}]
<input type="hidden" name="fnc" value="d3TotpCancelTotpLogin"> <input type="hidden" name="fnc" value="cancelTotplogin">
<input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]"> <input type="hidden" name="cl" value="[{$oView->getPreviousClass()}]">
[{$navFormParams}] [{$navFormParams}]

View File

@ -18,6 +18,7 @@ namespace D3\Totp\Modules\Application\Component;
use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\d3totp;
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException; use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use InvalidArgumentException;
use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
@ -28,29 +29,31 @@ use OxidEsales\Eshop\Core\UtilsView;
class d3_totp_UserComponent extends d3_totp_UserComponent_parent class d3_totp_UserComponent extends d3_totp_UserComponent_parent
{ {
/** /**
* @return void * @param User $oUser
*
* @return string
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function login() protected function _afterLogin($oUser)
{ {
parent::login(); if (!$oUser instanceof User) {
throw oxNew( InvalidArgumentException::class, 'user argument must an instance of User class');
}
$oUser = $this->getUser(); if ($oUser->getId()) {
if ($oUser instanceof User && $oUser->getId()) {
$totp = $this->d3GetTotpObject(); $totp = $this->d3GetTotpObject();
$totp->loadByUserId($oUser->getId()); $totp->loadByUserId($oUser->getId());
if ($totp->isActive() if ($totp->isActive()
&& !$this->d3TotpGetSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) && !$this->d3GetSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
) { ) {
$this->d3TotpGetSession()->setVariable( $this->d3GetSession()->setVariable(
d3totp::TOTP_SESSION_CURRENTCLASS, d3totp::TOTP_SESSION_CURRENTCLASS,
$this->getParent()->getClassKey() != 'd3totplogin' ? $this->getParent()->getClassKey() : 'start' $this->getParent()->getClassKey() != 'd3totplogin' ? $this->getParent()->getClassKey() : 'start'
); );
$this->d3TotpGetSession()->setVariable(d3totp::TOTP_SESSION_CURRENTUSER, $oUser->getId()); $this->d3GetSession()->setVariable(d3totp::TOTP_SESSION_CURRENTUSER, $oUser->getId());
$this->d3TotpGetSession()->setVariable( $this->d3GetSession()->setVariable(
d3totp::TOTP_SESSION_NAVFORMPARAMS, d3totp::TOTP_SESSION_NAVFORMPARAMS,
$this->getParent()->getViewConfig()->getNavFormParams() $this->getParent()->getViewConfig()->getNavFormParams()
); );
@ -58,9 +61,11 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
$oUser->logout(); $oUser->logout();
$sUrl = Registry::getConfig()->getShopHomeUrl() . 'cl=d3totplogin'; $sUrl = Registry::getConfig()->getShopHomeUrl() . 'cl=d3totplogin';
$this->d3TotpGetUtils()->redirect($sUrl, false); $this->d3GetUtils()->redirect($sUrl, false);
} }
} }
return parent::_afterLogin($oUser);
} }
/** /**
@ -75,7 +80,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
* @throws DBALException * @throws DBALException
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function d3TotpCheckTotpLogin() public function checkTotplogin()
{ {
$sTotp = Registry::getRequest()->getRequestEscapedParameter('d3totp', true); $sTotp = Registry::getRequest()->getRequestEscapedParameter('d3totp', true);
@ -87,10 +92,10 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
$totp->loadByUserId($sUserId); $totp->loadByUserId($sUserId);
try { try {
if (!$this->d3TotpIsNoTotpOrNoLogin($totp) && $this->d3TotpHasValidTotp($sTotp, $totp)) { if (!$this->isNoTotpOrNoLogin($totp) && $this->hasValidTotp($sTotp, $totp)) {
// relogin, don't extract from this try block // relogin, don't extract from this try block
$this->d3TotpGetSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp); $this->d3GetSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp);
$this->d3TotpGetSession()->setVariable('usr', $oUser->getId()); $this->d3GetSession()->setVariable('usr', $oUser->getId());
$this->setUser(null); $this->setUser(null);
$this->setLoginStatus(USER_LOGIN_SUCCESS); $this->setLoginStatus(USER_LOGIN_SUCCESS);
$this->_afterLogin($oUser); $this->_afterLogin($oUser);
@ -100,7 +105,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
return false; return false;
} }
} catch (d3totp_wrongOtpException $oEx) { } catch (d3totp_wrongOtpException $oEx) {
$this->d3TotpGetUtilsView()->addErrorToDisplay($oEx, false, false, "", 'd3totplogin'); $this->d3GetUtilsView()->addErrorToDisplay($oEx, false, false, "", 'd3totplogin');
} }
return 'd3totplogin'; return 'd3totplogin';
@ -109,7 +114,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
/** /**
* @return UtilsView * @return UtilsView
*/ */
public function d3TotpGetUtilsView(): UtilsView public function d3GetUtilsView()
{ {
return Registry::getUtilsView(); return Registry::getUtilsView();
} }
@ -117,12 +122,12 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
/** /**
* @return Utils * @return Utils
*/ */
public function d3TotpGetUtils() public function d3GetUtils()
{ {
return Registry::getUtils(); return Registry::getUtils();
} }
public function d3TotpCancelTotpLogin() public function cancelTotpLogin()
{ {
$this->d3TotpClearSessionVariables(); $this->d3TotpClearSessionVariables();
@ -133,7 +138,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
* @param d3totp $totp * @param d3totp $totp
* @return bool * @return bool
*/ */
public function d3TotpIsNoTotpOrNoLogin($totp) public function isNoTotpOrNoLogin($totp)
{ {
return false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTUSER) return false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTUSER)
|| false == $totp->isActive(); || false == $totp->isActive();
@ -146,7 +151,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
* @throws d3totp_wrongOtpException * @throws d3totp_wrongOtpException
*/ */
public function d3TotpHasValidTotp($sTotp, $totp) public function hasValidTotp($sTotp, $totp)
{ {
return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) || return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) ||
( (
@ -156,15 +161,15 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
public function d3TotpClearSessionVariables() public function d3TotpClearSessionVariables()
{ {
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTCLASS); $this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTCLASS);
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTUSER); $this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_CURRENTUSER);
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_NAVFORMPARAMS); $this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_NAVFORMPARAMS);
} }
/** /**
* @return Session * @return Session
*/ */
public function d3TotpGetSession(): Session public function d3GetSession()
{ {
return Registry::getSession(); return Registry::getSession();
} }

View File

@ -163,14 +163,14 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
public function d3CancelLogin() public function d3CancelLogin()
{ {
$oUser = $this->d3GetUserObject(); $oUser = $this->d3TotpGetUserObject();
$oUser->logout(); $oUser->logout();
} }
/** /**
* @return User * @return User
*/ */
public function d3GetUserObject() public function d3TotpGetUserObject()
{ {
return oxNew(User::class); return oxNew(User::class);
} }

View File

@ -36,7 +36,7 @@ trait d3_totp_getUserTrait
$totp->loadByUserId($oUser->getId()); $totp->loadByUserId($oUser->getId());
if ($totp->isActive() if ($totp->isActive()
&& !$this->d3GetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME) && !$this->d3TotpGetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME)
) { ) {
return false; return false;
} }
@ -56,7 +56,7 @@ trait d3_totp_getUserTrait
/** /**
* @return Session * @return Session
*/ */
public function d3GetSessionObject() public function d3TotpGetSessionObject()
{ {
return Registry::getSession(); return Registry::getSession();
} }

View File

@ -25,7 +25,7 @@ class d3_totp_user extends d3_totp_user_parent
{ {
$return = parent::logout(); $return = parent::logout();
$this->d3TotpGetSession()->deleteVariable(d3totp::TOTP_SESSION_VARNAME); $this->d3GetSession()->deleteVariable(d3totp::TOTP_SESSION_VARNAME);
return $return; return $return;
} }
@ -41,7 +41,7 @@ class d3_totp_user extends d3_totp_user_parent
/** /**
* @return Session * @return Session
*/ */
public function d3TotpGetSession() public function d3GetSession()
{ {
return Registry::getSession(); return Registry::getSession();
} }

View File

@ -34,8 +34,8 @@ class d3_totp_utils extends d3_totp_utils_parent
$blAuth = parent::checkAccessRights(); $blAuth = parent::checkAccessRights();
$blAuth = $this->d3AuthHook($blAuth); $blAuth = $this->d3AuthHook($blAuth);
$userID = $this->d3GetSessionObject()->getVariable("auth"); $userID = $this->d3TotpGetSessionObject()->getVariable("auth");
$totpAuth = (bool) $this->d3GetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME); $totpAuth = (bool) $this->d3TotpGetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME);
/** @var d3totp $totp */ /** @var d3totp $totp */
$totp = $this->d3GetTotpObject(); $totp = $this->d3GetTotpObject();
$totp->loadByUserId($userID); $totp->loadByUserId($userID);
@ -70,7 +70,7 @@ class d3_totp_utils extends d3_totp_utils_parent
/** /**
* @return Session * @return Session
*/ */
public function d3GetSessionObject() public function d3TotpGetSessionObject()
{ {
return Registry::getSession(); return Registry::getSession();
} }

View File

@ -92,7 +92,7 @@ class d3force_2faTest extends d3user_totpTest
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Application\Controller\Admin\d3force_2fa::d3GetSessionObject * @covers \D3\Totp\Application\Controller\Admin\d3force_2fa::d3TotpGetSessionObject
*/ */
public function testD3GetSessionObject() public function testD3GetSessionObject()
{ {
@ -100,7 +100,7 @@ class d3force_2faTest extends d3user_totpTest
Session::class, Session::class,
$this->callMethod( $this->callMethod(
$this->_oController, $this->_oController,
'd3GetSessionObject' 'd3TotpGetSessionObject'
) )
); );
} }

View File

@ -109,9 +109,9 @@ class d3backupcodeTest extends d3TotpUnitTestCase
/** @var d3backupcode|MockObject $oModelMock */ /** @var d3backupcode|MockObject $oModelMock */
$oModelMock = $this->getMockBuilder(d3backupcode::class) $oModelMock = $this->getMockBuilder(d3backupcode::class)
->onlyMethods(['d3GetUserObject']) ->onlyMethods(['d3TotpGetUserObject'])
->getMock(); ->getMock();
$oModelMock->method('d3GetUserObject')->willReturn($oUserMock); $oModelMock->method('d3TotpGetUserObject')->willReturn($oUserMock);
$this->_oModel = $oModelMock; $this->_oModel = $oModelMock;
@ -169,13 +169,13 @@ class d3backupcodeTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Application\Model\d3backupcode::d3GetUserObject * @covers \D3\Totp\Application\Model\d3backupcode::d3TotpGetUserObject
*/ */
public function d3getUserObjectReturnsRightInstance() public function d3getUserObjectReturnsRightInstance()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
User::class, User::class,
$this->callMethod($this->_oModel, 'd3GetUserObject') $this->callMethod($this->_oModel, 'd3TotpGetUserObject')
); );
} }
} }

View File

@ -17,6 +17,7 @@ use D3\Totp\Application\Model\d3totp;
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException; use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
use D3\Totp\Modules\Application\Component\d3_totp_UserComponent; use D3\Totp\Modules\Application\Component\d3_totp_UserComponent;
use D3\Totp\tests\unit\d3TotpUnitTestCase; use D3\Totp\tests\unit\d3TotpUnitTestCase;
use InvalidArgumentException;
use OxidEsales\Eshop\Application\Component\UserComponent; use OxidEsales\Eshop\Application\Component\UserComponent;
use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Controller\BaseController; use OxidEsales\Eshop\Core\Controller\BaseController;
@ -54,9 +55,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
*/ */
public function loginFailsIfNoUserLoggedIn() public function afterLoginFailsIfNoUserLoggedIn()
{ {
$oUser = false; $oUser = false;
@ -82,31 +83,29 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'getUser',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
'd3TotpGetUtils', 'd3GetUtils',
]) ])
->getMock(); ->getMock();
$oControllerMock->method('getUser')->willReturn($oUser);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock); $oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
$_GET['lgn_usr'] = 'username';
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->callMethod($this->_oController, 'login'); $this->expectException( InvalidArgumentException::class);
$this->callMethod($this->_oController, '_afterLogin', [$oUser]);
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
* @dataProvider loginFailTotpNotActiveOrAlreadyCheckedDataProvider * @dataProvider afterLoginFailTotpNotActiveOrAlreadyCheckedDataProvider
*/ */
public function loginFailTotpNotActiveOrAlreadyChecked($isActive, $checked) public function afterLoginFailTotpNotActiveOrAlreadyChecked($isActive, $checked)
{ {
/** @var User|MockObject $oUserMock */ /** @var User|MockObject $oUserMock */
$oUserMock = $this->getMockBuilder(User::class) $oUserMock = $this->getMockBuilder(User::class)
@ -145,28 +144,24 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'getUser',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
'd3TotpGetUtils', 'd3GetUtils',
]) ])
->getMock(); ->getMock();
$oControllerMock->method('getUser')->willReturn($oUserMock);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock); $oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
$_GET['lgn_usr'] = 'username';
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->callMethod($this->_oController, 'login'); $this->callMethod($this->_oController, '_afterLogin', [$oUserMock]);
} }
/** /**
* @return array * @return array
*/ */
public function loginFailTotpNotActiveOrAlreadyCheckedDataProvider(): array public function afterLoginFailTotpNotActiveOrAlreadyCheckedDataProvider(): array
{ {
return [ return [
'TOTP not active, not checked' => [false, null], 'TOTP not active, not checked' => [false, null],
@ -178,9 +173,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::login * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::_afterLogin
*/ */
public function loginPass() public function afterLoginPass()
{ {
/** @var User|MockObject $oUserMock */ /** @var User|MockObject $oUserMock */
$oUserMock = $this->getMockBuilder(User::class) $oUserMock = $this->getMockBuilder(User::class)
@ -225,24 +220,20 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'getUser',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
'd3TotpGetUtils', 'd3GetUtils',
'getParent' 'getParent'
]) ])
->getMock(); ->getMock();
$oControllerMock->method('getUser')->willReturn($oUserMock);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('getParent')->willReturn($oParentMock); $oControllerMock->method('getParent')->willReturn($oParentMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock); $oControllerMock->method('d3GetUtils')->willReturn($oUtilsMock);
$_GET['lgn_usr'] = 'username';
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->callMethod($this->_oController, 'login'); $this->callMethod($this->_oController, '_afterLogin', [$oUserMock]);
} }
/** /**
@ -261,7 +252,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
*/ */
public function checkTotploginNoTotpLogin() public function checkTotploginNoTotpLogin()
{ {
@ -281,29 +272,29 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'd3TotpIsNoTotpOrNoLogin', 'isNoTotpOrNoLogin',
'd3TotpHasValidTotp', 'hasValidTotp',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
]) ])
->getMock(); ->getMock();
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(true); $oControllerMock->method('isNoTotpOrNoLogin')->willReturn(true);
$oControllerMock->expects($this->never())->method('d3TotpHasValidTotp')->willReturn(false); $oControllerMock->expects($this->never())->method('hasValidTotp')->willReturn(false);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->assertSame( $this->assertSame(
'd3totplogin', 'd3totplogin',
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin') $this->callMethod($this->_oController, 'checkTotplogin')
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
*/ */
public function checkTotploginUnvalidTotp() public function checkTotploginUnvalidTotp()
{ {
@ -334,31 +325,31 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'd3TotpIsNoTotpOrNoLogin', 'isNoTotpOrNoLogin',
'd3TotpHasValidTotp', 'hasValidTotp',
'd3TotpGetUtilsView', 'd3GetUtilsView',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
]) ])
->getMock(); ->getMock();
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false); $oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
$oControllerMock->expects($this->once())->method('d3TotpHasValidTotp')->willThrowException($oTotpExceptionMock); $oControllerMock->expects($this->once())->method('hasValidTotp')->willThrowException($oTotpExceptionMock);
$oControllerMock->method('d3TotpGetUtilsView')->willReturn($oUtilsViewMock); $oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->assertSame( $this->assertSame(
'd3totplogin', 'd3totplogin',
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin') $this->callMethod($this->_oController, 'checkTotplogin')
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCheckTotpLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::checkTotplogin
*/ */
public function checkTotploginValidTotp() public function checkTotploginValidTotp()
{ {
@ -384,19 +375,19 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods([ ->onlyMethods([
'd3TotpIsNoTotpOrNoLogin', 'isNoTotpOrNoLogin',
'd3TotpHasValidTotp', 'hasValidTotp',
'd3TotpGetUtilsView', 'd3GetUtilsView',
'd3GetTotpObject', 'd3GetTotpObject',
'd3TotpGetSession', 'd3GetSession',
'setLoginStatus' 'setLoginStatus'
]) ])
->getMock(); ->getMock();
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false); $oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
$oControllerMock->expects($this->once())->method('d3TotpHasValidTotp')->willReturn(true); $oControllerMock->expects($this->once())->method('hasValidTotp')->willReturn(true);
$oControllerMock->method('d3TotpGetUtilsView')->willReturn($oUtilsViewMock); $oControllerMock->method('d3GetUtilsView')->willReturn($oUtilsViewMock);
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$oControllerMock->expects($this->once())->method('setLoginStatus')->with( $oControllerMock->expects($this->once())->method('setLoginStatus')->with(
$this->identicalTo(USER_LOGIN_SUCCESS) $this->identicalTo(USER_LOGIN_SUCCESS)
); );
@ -404,27 +395,27 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->assertFalse( $this->assertFalse(
$this->callMethod($this->_oController, 'd3TotpCheckTotpLogin') $this->callMethod($this->_oController, 'checkTotplogin')
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpGetUtilsView * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3GetUtilsView
*/ */
public function d3GetUtilsViewReturnsRightInstance() public function d3GetUtilsViewReturnsRightInstance()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
UtilsView::class, UtilsView::class,
$this->callMethod($this->_oController, 'd3TotpGetUtilsView') $this->callMethod($this->_oController, 'd3GetUtilsView')
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpCancelTotpLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::cancelTotpLogin
*/ */
public function canCancelTotpLogin() public function canCancelTotpLogin()
{ {
@ -436,13 +427,13 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
$this->callMethod($this->_oController, 'd3TotpCancelTotpLogin'); $this->callMethod($this->_oController, 'cancelTotpLogin');
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
*/ */
public function isNoTotpOrNoLoginTrueNoSessionVariable() public function isNoTotpOrNoLoginTrueNoSessionVariable()
{ {
@ -456,14 +447,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(true); $oTotpMock->method('isActive')->willReturn(true);
$this->assertTrue( $this->assertTrue(
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock]) $this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
*/ */
public function isNoTotpOrNoLoginTrueTotpNotActive() public function isNoTotpOrNoLoginTrueTotpNotActive()
{ {
@ -477,14 +468,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(false); $oTotpMock->method('isActive')->willReturn(false);
$this->assertTrue( $this->assertTrue(
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock]) $this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpIsNoTotpOrNoLogin * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::isNoTotpOrNoLogin
*/ */
public function isNoTotpOrNoLoginFalse() public function isNoTotpOrNoLoginFalse()
{ {
@ -498,14 +489,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(true); $oTotpMock->method('isActive')->willReturn(true);
$this->assertFalse( $this->assertFalse(
$this->callMethod($this->_oController, 'd3TotpIsNoTotpOrNoLogin', [$oTotpMock]) $this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
*/ */
public function hasValidTotpTrueSessionVarname() public function hasValidTotpTrueSessionVarname()
{ {
@ -519,14 +510,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false); $oTotpMock->method('verify')->willReturn(false);
$this->assertTrue( $this->assertTrue(
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock]) $this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
*/ */
public function hasValidTotpTrueValidTotp() public function hasValidTotpTrueValidTotp()
{ {
@ -540,14 +531,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true); $oTotpMock->method('verify')->willReturn(true);
$this->assertTrue( $this->assertTrue(
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock]) $this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
*/ */
public function hasValidTotpFalseMissingTotp() public function hasValidTotpFalseMissingTotp()
{ {
@ -561,14 +552,14 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true); $oTotpMock->method('verify')->willReturn(true);
$this->assertFalse( $this->assertFalse(
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock]) $this->callMethod($this->_oController, 'hasValidTotp', [null, $oTotpMock])
); );
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpHasValidTotp * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::hasValidTotp
*/ */
public function hasValidTotpFalseUnverifiedTotp() public function hasValidTotpFalseUnverifiedTotp()
{ {
@ -582,7 +573,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false); $oTotpMock->method('verify')->willReturn(false);
$this->assertFalse( $this->assertFalse(
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', ['123456', $oTotpMock]) $this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
); );
} }
@ -601,9 +592,9 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** @var UserComponent|MockObject $oControllerMock */ /** @var UserComponent|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(UserComponent::class) $oControllerMock = $this->getMockBuilder(UserComponent::class)
->onlyMethods(['d3TotpGetSession']) ->onlyMethods(['d3GetSession'])
->getMock(); ->getMock();
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
@ -613,13 +604,13 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3TotpGetSession * @covers \D3\Totp\Modules\Application\Component\d3_totp_UserComponent::d3GetSession
*/ */
public function d3GetSessionReturnsRightInstance() public function d3GetSessionReturnsRightInstance()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
Session::class, Session::class,
$this->callMethod($this->_oController, 'd3TotpGetSession') $this->callMethod($this->_oController, 'd3GetSession')
); );
} }
} }

View File

@ -691,9 +691,9 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
/** @var d3_totp_LoginController|MockObject $oControllerMock */ /** @var d3_totp_LoginController|MockObject $oControllerMock */
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class) $oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods(['d3GetUserObject']) ->onlyMethods(['d3TotpGetUserObject'])
->getMock(); ->getMock();
$oControllerMock->method('d3GetUserObject')->willReturn($oUserMock); $oControllerMock->method('d3TotpGetUserObject')->willReturn($oUserMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
@ -703,13 +703,13 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController::d3GetUserObject * @covers \D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController::d3TotpGetUserObject
*/ */
public function d3GetUserObjectReturnsRightObject() public function d3GetUserObjectReturnsRightObject()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
User::class, User::class,
$this->callMethod($this->_oController, 'd3GetUserObject') $this->callMethod($this->_oController, 'd3TotpGetUserObject')
); );
} }

View File

@ -80,11 +80,11 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass) $oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([ ->onlyMethods([
'd3GetTotpObject', 'd3GetTotpObject',
'd3GetSessionObject', 'd3TotpGetSessionObject',
]) ])
->getMock(); ->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock); $oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
@ -131,11 +131,11 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass) $oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([ ->onlyMethods([
'd3GetTotpObject', 'd3GetTotpObject',
'd3GetSessionObject', 'd3TotpGetSessionObject',
]) ])
->getMock(); ->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock); $oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
@ -183,11 +183,11 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass) $oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([ ->onlyMethods([
'd3GetTotpObject', 'd3GetTotpObject',
'd3GetSessionObject', 'd3TotpGetSessionObject',
]) ])
->getMock(); ->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock); $oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
$oControllerMock->method('d3GetSessionObject')->willReturn($oSessionMock); $oControllerMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
$this->_oController = $oControllerMock; $this->_oController = $oControllerMock;
@ -216,9 +216,9 @@ trait d3_totp_getUserTestTrait
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_OrderController::d3GetSessionObject * @covers \D3\Totp\Modules\Application\Controller\d3_totp_OrderController::d3TotpGetSessionObject
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_PaymentController::d3GetSessionObject * @covers \D3\Totp\Modules\Application\Controller\d3_totp_PaymentController::d3TotpGetSessionObject
* @covers \D3\Totp\Modules\Application\Controller\d3_totp_UserController::d3GetSessionObject * @covers \D3\Totp\Modules\Application\Controller\d3_totp_UserController::d3TotpGetSessionObject
*/ */
public function d3GetSessionObjectReturnsRightObject() public function d3GetSessionObjectReturnsRightObject()
{ {
@ -226,7 +226,7 @@ trait d3_totp_getUserTestTrait
Session::class, Session::class,
$this->callMethod( $this->callMethod(
$this->_oController, $this->_oController,
'd3GetSessionObject' 'd3TotpGetSessionObject'
) )
); );
} }

View File

@ -58,9 +58,9 @@ class d3_totp_userTest extends d3TotpUnitTestCase
/** @var d3_totp_user|MockObject $oModelMock */ /** @var d3_totp_user|MockObject $oModelMock */
$oModelMock = $this->getMockBuilder(User::class) $oModelMock = $this->getMockBuilder(User::class)
->onlyMethods(['d3TotpGetSession']) ->onlyMethods(['d3GetSession'])
->getMock(); ->getMock();
$oModelMock->method('d3TotpGetSession')->willReturn($oSessionMock); $oModelMock->method('d3GetSession')->willReturn($oSessionMock);
$this->_oModel = $oModelMock; $this->_oModel = $oModelMock;
@ -88,13 +88,13 @@ class d3_totp_userTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3TotpGetSession * @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3GetSession
*/ */
public function d3GetSessionReturnsRightInstance() public function d3GetSessionReturnsRightInstance()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
Session::class, Session::class,
$this->callMethod($this->_oModel, 'd3TotpGetSession') $this->callMethod($this->_oModel, 'd3GetSession')
); );
} }
} }

View File

@ -182,13 +182,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
$oCoreMock = $this->getMockBuilder(Utils::class) $oCoreMock = $this->getMockBuilder(Utils::class)
->onlyMethods([ ->onlyMethods([
'd3GetTotpObject', 'd3GetTotpObject',
'd3GetSessionObject', 'd3TotpGetSessionObject',
'fetchRightsForUser', 'fetchRightsForUser',
'redirect', 'redirect',
]) ])
->getMock(); ->getMock();
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oCoreMock->method('d3GetSessionObject')->willReturn($oSessionMock); $oCoreMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
$oCoreMock->method('fetchRightsForUser')->willReturn('malladmin'); $oCoreMock->method('fetchRightsForUser')->willReturn('malladmin');
$oCoreMock->expects($this->never())->method('redirect')->willReturn(true); $oCoreMock->expects($this->never())->method('redirect')->willReturn(true);
@ -235,13 +235,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
$oCoreMock = $this->getMockBuilder(Utils::class) $oCoreMock = $this->getMockBuilder(Utils::class)
->onlyMethods([ ->onlyMethods([
'd3GetTotpObject', 'd3GetTotpObject',
'd3GetSessionObject', 'd3TotpGetSessionObject',
'fetchRightsForUser', 'fetchRightsForUser',
'redirect', 'redirect',
]) ])
->getMock(); ->getMock();
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock); $oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
$oCoreMock->method('d3GetSessionObject')->willReturn($oSessionMock); $oCoreMock->method('d3TotpGetSessionObject')->willReturn($oSessionMock);
$oCoreMock->method('fetchRightsForUser')->willReturn('malladmin'); $oCoreMock->method('fetchRightsForUser')->willReturn('malladmin');
$oCoreMock->expects($this->once())->method('redirect')->willReturn(true); $oCoreMock->expects($this->once())->method('redirect')->willReturn(true);
@ -253,13 +253,13 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\Totp\Modules\Core\d3_totp_utils::d3GetSessionObject * @covers \D3\Totp\Modules\Core\d3_totp_utils::d3TotpGetSessionObject
*/ */
public function d3GetSessionObjectReturnsRightInstance() public function d3GetSessionObjectReturnsRightInstance()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
Session::class, Session::class,
$this->callMethod($this->_oCoreClass, 'd3GetSessionObject') $this->callMethod($this->_oCoreClass, 'd3TotpGetSessionObject')
); );
} }