apply PHP-CS-Fixer rule sets

This commit is contained in:
Daniel Seifert 2022-09-30 21:06:30 +02:00
parent 8e0480898a
commit ecb8b61923
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
43 changed files with 229 additions and 196 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
src/tests/.phpunit.result.cache
src/tests/reports/
.php_cs.cache

13
.php-cs-fixer.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP73Migration' => true,
'@PSR12' => true
])
->setFinder($finder)
;

View File

@ -45,6 +45,9 @@
"bacon/bacon-qr-code": "^2.0",
"laminas/laminas-math": "^3.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19"
},
"suggest": {
"d3/modcfg": "Provides automatic installation routines"
},

View File

@ -100,7 +100,7 @@ class d3_account_totp extends AccountController
$aParams = [
'd3totp__usetotp' => 1,
'd3totp__oxuserid' => $oUser->getId()
'd3totp__oxuserid' => $oUser->getId(),
];
$seed = Registry::getRequest()->getRequestEscapedParameter("secret");
$otp = Registry::getRequest()->getRequestEscapedParameter("otp");

View File

@ -19,7 +19,7 @@ use Laminas\Math\Rand;
class d3RandomGenerator extends Rand
{
const CHAR_DIGITS = '0123456789';
public const CHAR_DIGITS = '0123456789';
/**
* @return string

View File

@ -29,10 +29,10 @@ use OxidEsales\Eshop\Core\Registry;
class d3totp extends BaseModel
{
const TOTP_SESSION_VARNAME = 'totp_auth';
const TOTP_SESSION_CURRENTUSER = 'd3totpCurrentUser';
const TOTP_SESSION_CURRENTCLASS = 'd3totpCurrentClass';
const TOTP_SESSION_NAVFORMPARAMS = 'd3totpNavFormParams';
public const TOTP_SESSION_VARNAME = 'totp_auth';
public const TOTP_SESSION_CURRENTUSER = 'd3totpCurrentUser';
public const TOTP_SESSION_CURRENTCLASS = 'd3totpCurrentClass';
public const TOTP_SESSION_NAVFORMPARAMS = 'd3totpNavFormParams';
public $tableName = 'd3totp';
public $userId;
@ -189,7 +189,7 @@ class d3totp extends BaseModel
{
$this->assign(
[
'seed' => $this->encrypt($seed)
'seed' => $this->encrypt($seed),
]
);
}

View File

@ -51,5 +51,5 @@ $aLang = [
'D3_TOTP_ERROR_UNVALID' => 'Das Einmalpasswort ist ungültig.',
'D3_TOTP_ALREADY_EXIST' => 'Die Registrierung wurde schon gespeichert.',
'SHOP_MODULE_D3_TOTP_ADMIN_FORCE_2FA' => 'Administratoren sind verpflichtet 2FA zu aktivieren'
'SHOP_MODULE_D3_TOTP_ADMIN_FORCE_2FA' => 'Administratoren sind verpflichtet 2FA zu aktivieren',
];

View File

@ -51,5 +51,5 @@ $aLang = [
'D3_TOTP_ERROR_UNVALID' => 'The one-time password is invalid.',
'D3_TOTP_ALREADY_EXIST' => 'The registration has already been saved.',
'SHOP_MODULE_D3_TOTP_ADMIN_FORCE_2FA' => 'Administrators are required to activate 2FA'
'SHOP_MODULE_D3_TOTP_ADMIN_FORCE_2FA' => 'Administrators are required to activate 2FA',
];

View File

@ -16,7 +16,9 @@ namespace D3\Totp\Modules\Application\Component
use OxidEsales\Eshop\Application\Component\UserComponent;
class d3_totp_UserComponent_parent extends UserComponent { }
class d3_totp_UserComponent_parent extends UserComponent
{
}
}
namespace D3\Totp\Modules\Application\Controller
@ -26,11 +28,17 @@ namespace D3\Totp\Modules\Application\Controller
use OxidEsales\Eshop\Application\Controller\PaymentController;
use OxidEsales\Eshop\Application\Controller\UserController;
class d3_totp_UserController_parent extends UserController { }
class d3_totp_UserController_parent extends UserController
{
}
class d3_totp_PaymentController_parent extends PaymentController { }
class d3_totp_PaymentController_parent extends PaymentController
{
}
class d3_totp_OrderController_parent extends OrderController { }
class d3_totp_OrderController_parent extends OrderController
{
}
}
namespace D3\Totp\Modules\Application\Controller\Admin
@ -38,7 +46,9 @@ namespace D3\Totp\Modules\Application\Controller\Admin
use OxidEsales\Eshop\Application\Controller\Admin\LoginController;
class d3_totp_LoginController_parent extends LoginController { }
class d3_totp_LoginController_parent extends LoginController
{
}
}
namespace D3\Totp\Modules\Application\Model
@ -46,7 +56,9 @@ namespace D3\Totp\Modules\Application\Model
use OxidEsales\Eshop\Application\Model\User;
class d3_totp_user_parent extends User { }
class d3_totp_user_parent extends User
{
}
}
namespace D3\Totp\Modules\Core
@ -54,5 +66,7 @@ namespace D3\Totp\Modules\Core
use OxidEsales\Eshop\Core\Utils;
class d3_totp_utils_parent extends Utils { }
class d3_totp_utils_parent extends Utils
{
}
}

View File

@ -46,7 +46,8 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
) {
Registry::getSession()->setVariable(
d3totp::TOTP_SESSION_CURRENTCLASS,
$this->getParent()->getClassKey() != 'd3totplogin' ? $this->getParent()->getClassKey() : 'start');
$this->getParent()->getClassKey() != 'd3totplogin' ? $this->getParent()->getClassKey() : 'start'
);
Registry::getSession()->setVariable(d3totp::TOTP_SESSION_CURRENTUSER, $oUser->getId());
Registry::getSession()->setVariable(
d3totp::TOTP_SESSION_NAVFORMPARAMS,

View File

@ -18,6 +18,7 @@ namespace D3\Totp\Setup;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
// @codeCoverageIgnoreStart
class Events
{

View File

@ -84,7 +84,7 @@ $aModule = [
'name' => 'D3_TOTP_ADMIN_FORCE_2FA',
'type' => 'bool',
'value' => false,
]
],
],
'events' => [
'onActivate' => ModuleSetup\Events::class.'::onActivate',
@ -101,5 +101,5 @@ $aModule = [
'block' => 'account_menu',
'file' => 'Application/views/blocks/page/account/inc/account_menu.tpl',
],
]
],
];

View File

@ -12,6 +12,7 @@
*/
// Include totp test config
namespace D3\Totp\tests;
use D3\ModCfg\Tests\additional_abstract;

View File

@ -12,4 +12,3 @@
*/
const D3TOTP_REQUIRE_MODCFG = true;

View File

@ -84,7 +84,7 @@ class d3force_2faTest extends d3user_totpTest
'noAdmin' => [false, false, true, 'userId'],
'dont force' => [false, true, false, 'userId'],
'no user id' => [false, true, true, null],
'passed' => [true, true, true, 'userId']
'passed' => [true, true, true, 'userId'],
];
}

View File

@ -56,7 +56,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3user_totp::class)
->onlyMethods([
'getEditObjectId',
'getUserObject'
'getUserObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('-1');
@ -65,7 +65,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$sTpl = $this->callMethod($this->_oController, 'render');
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('edit'));
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', ['edit']);
$this->assertSame('d3user_totp.tpl', $sTpl);
$this->assertSame($tplUser, null);
@ -93,7 +93,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3user_totp::class)
->onlyMethods([
'getEditObjectId',
'getUserObject'
'getUserObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -102,8 +102,8 @@ class d3user_totpTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$sTpl = $this->callMethod($this->_oController, 'render');
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('edit'));
$oxid = $this->callMethod($this->_oController, 'getViewDataElement', array('oxid'));
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', ['edit']);
$oxid = $this->callMethod($this->_oController, 'getViewDataElement', ['oxid']);
$this->assertSame('d3user_totp.tpl', $sTpl);
$this->assertSame($tplUser, $oUserMock);
@ -133,7 +133,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
->onlyMethods([
'getEditObjectId',
'getUserObject',
'addTplParam'
'addTplParam',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -151,8 +151,8 @@ class d3user_totpTest extends d3TotpUnitTestCase
$this->setValue($this->_oController, '_sSaveError', 'foo');
$sTpl = $this->callMethod($this->_oController, 'render');
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('edit'));
$oxid = $this->callMethod($this->_oController, 'getViewDataElement', array('oxid'));
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', ['edit']);
$oxid = $this->callMethod($this->_oController, 'getViewDataElement', ['oxid']);
$this->assertSame('d3user_totp.tpl', $sTpl);
$this->assertNull($tplUser);
@ -228,7 +228,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'verify',
'saveSecret',
'assign',
'checkIfAlreadyExist'
'checkIfAlreadyExist',
])
->disableOriginalConstructor()
->getMock();
@ -245,7 +245,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'getEditObjectId',
'getUserObject',
'getTotpObject',
'getBackupcodeListObject'
'getBackupcodeListObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -279,7 +279,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'verify',
'saveSecret',
'assign',
'checkIfAlreadyExist'
'checkIfAlreadyExist',
])
->getMock();
$oTotpMock->method('load')->willReturn(true);
@ -295,7 +295,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'getEditObjectId',
'getUserObject',
'getTotpObject',
'getBackupcodeListObject'
'getBackupcodeListObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -318,7 +318,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$oBackupCodeListMock = $this->getMockBuilder(d3backupcodelist::class)
->onlyMethods([
'save',
'generateBackupCodes'
'generateBackupCodes',
])
->getMock();
$oBackupCodeListMock->expects($this->once())->method('save')->willReturn(true);
@ -332,7 +332,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'verify',
'saveSecret',
'assign',
'checkIfAlreadyExist'
'checkIfAlreadyExist',
])
->disableOriginalConstructor()
->getMock();
@ -349,7 +349,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'getEditObjectId',
'getUserObject',
'getTotpObject',
'getBackupcodeListObject'
'getBackupcodeListObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -369,7 +369,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
public function canSaveWithKnownOXID()
{
$aEditval = [
'd3totp__oxid' => 'foo'
'd3totp__oxid' => 'foo',
];
$_GET['editval'] = $aEditval;
@ -377,7 +377,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$oBackupCodeListMock = $this->getMockBuilder(d3backupcodelist::class)
->onlyMethods([
'save',
'generateBackupCodes'
'generateBackupCodes',
])
->getMock();
$oBackupCodeListMock->expects($this->once())->method('save')->willReturn(true);
@ -391,7 +391,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'verify',
'saveSecret',
'assign',
'checkIfAlreadyExist'
'checkIfAlreadyExist',
])
->disableOriginalConstructor()
->getMock();
@ -408,7 +408,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
'getEditObjectId',
'getUserObject',
'getTotpObject',
'getBackupcodeListObject'
'getBackupcodeListObject',
])
->getMock();
$oControllerMock->method('getEditObjectId')->willReturn('foobar');
@ -430,10 +430,10 @@ class d3user_totpTest extends d3TotpUnitTestCase
{
$aBackupList = [
'foo1',
'bar2'
'bar2',
];
$this->callMethod($this->_oController, 'setBackupCodes', array($aBackupList));
$this->callMethod($this->_oController, 'setBackupCodes', [$aBackupList]);
$aReturn = $this->callMethod($this->_oController, 'getBackupCodes');
@ -476,7 +476,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
public function canDelete()
{
$editval = [
'd3totp__oxid' => 'foo'
'd3totp__oxid' => 'foo',
];
$_GET['editval'] = $editval;
@ -485,7 +485,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
->disableOriginalConstructor()
->onlyMethods([
'delete',
'load'
'load',
])
->getMock();
$oTotpMock->expects($this->once())->method('delete')->willReturn(true);
@ -522,7 +522,7 @@ class d3user_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3user_totp::class)
->onlyMethods([
'getBackupCodeListObject',
'getUser'
'getUser',
])
->getMock();
$oControllerMock->method('getBackupCodeListObject')->willReturn($oBackupCodeListMock);

View File

@ -56,7 +56,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oUser->setId('foo');
$oUser->assign(
[
'oxpassword' => 'foo'
'oxpassword' => 'foo',
]
);
@ -69,7 +69,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$sTpl = $this->callMethod($this->_oController, 'render');
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('user'));
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', ['user']);
$this->assertSame('d3_account_totp.tpl', $sTpl);
$this->assertSame($tplUser, $oUser);
@ -94,7 +94,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$sTpl = $this->callMethod($this->_oController, 'render');
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', array('user'));
$tplUser = $this->callMethod($this->_oController, 'getViewDataElement', ['user']);
$this->assertSame('page/account/login.tpl', $sTpl);
$this->assertNull($tplUser);
@ -110,10 +110,10 @@ class d3_account_totpTest extends d3TotpUnitTestCase
{
$aBackupList = [
'foo1',
'bar2'
'bar2',
];
$this->callMethod($this->_oController, 'setBackupCodes', array($aBackupList));
$this->callMethod($this->_oController, 'setBackupCodes', [$aBackupList]);
$aReturn = $this->callMethod($this->_oController, 'getBackupCodes');
@ -156,7 +156,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_account_totp::class)
->onlyMethods([
'getBackupCodeListObject',
'getUser'
'getUser',
])
->getMock();
$oControllerMock->method('getBackupCodeListObject')->willReturn($oBackupCodeListMock);
@ -203,7 +203,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oBackupCodeListMock = $this->getMockBuilder(d3backupcodelist::class)
->onlyMethods([
'generateBackupCodes',
'save'
'save',
])
->getMock();
$oBackupCodeListMock->expects($this->never())->method('generateBackupCodes');
@ -216,7 +216,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
'saveSecret',
'assign',
'verify',
'save'
'save',
])
->getMock();
$oTotpMock->method('saveSecret')->willReturn(true);
@ -232,7 +232,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
->onlyMethods([
'getTotpObject',
'getUser',
'getBackupCodeListObject'
'getBackupCodeListObject',
])
->getMock();
$oControllerMock->method('getTotpObject')->willReturn($oTotpMock);
@ -257,7 +257,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oBackupCodeListMock = $this->getMockBuilder(d3backupcodelist::class)
->onlyMethods([
'generateBackupCodes',
'save'
'save',
])
->getMock();
$oBackupCodeListMock->method('generateBackupCodes')->willReturn(['0123', '1234']);
@ -289,7 +289,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
->onlyMethods([
'getTotpObject',
'getUser',
'getBackupCodeListObject'
'getBackupCodeListObject',
])
->getMock();
$oControllerMock->method('getTotpObject')->willReturn($oTotpMock);
@ -341,7 +341,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_account_totp::class)
->onlyMethods([
'getTotpObject',
'getUser'
'getUser',
])
->getMock();
$oControllerMock->method('getTotpObject')->willReturn($oTotpMock);
@ -366,7 +366,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
->disableOriginalConstructor()
->onlyMethods([
'delete',
'loadByUserId'
'loadByUserId',
])
->getMock();
$oTotpMock->expects($this->once())->method('delete')->willReturn(true);
@ -379,7 +379,7 @@ class d3_account_totpTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_account_totp::class)
->onlyMethods([
'getTotpObject',
'getUser'
'getUser',
])
->getMock();
$oControllerMock->method('getTotpObject')->willReturn($oTotpMock);

View File

@ -57,7 +57,7 @@ class d3backupcodeTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3backupcode::class)
->onlyMethods([
'getRandomTotpBackupCode',
'd3EncodeBC'
'd3EncodeBC',
])
->getMock();
$oModelMock->method('getRandomTotpBackupCode')->willReturn($sBackupCode);
@ -69,7 +69,7 @@ class d3backupcodeTest extends d3TotpUnitTestCase
$this->_oModel = $oModelMock;
$this->callMethod($this->_oModel, 'generateCode', array($sTestUserId));
$this->callMethod($this->_oModel, 'generateCode', [$sTestUserId]);
$this->assertSame($sTestUserId, $this->_oModel->getFieldData('oxuserid'));
$this->assertSame($sBackupCode, $this->_oModel->getFieldData('backupcode'));
@ -103,7 +103,7 @@ class d3backupcodeTest extends d3TotpUnitTestCase
$oUserMock->method('load')->willReturn(true);
$oUserMock->assign(
[
'oxpasssalt' => '6162636465666768696A6B'
'oxpasssalt' => '6162636465666768696A6B',
]
);
@ -134,7 +134,7 @@ class d3backupcodeTest extends d3TotpUnitTestCase
->getMock();
$oUserMock->assign(
[
'oxid' => 'foobar'
'oxid' => 'foobar',
]
);

View File

@ -75,7 +75,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'deleteAllFromUser',
'getD3BackupCodeObject',
'd3GetConfig'
'd3GetConfig',
])
->getMock();
$oModelMock->expects($this->once())->method('deleteAllFromUser')->willReturn(true);
@ -84,7 +84,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
$this->_oModel = $oModelMock;
$this->callMethod($this->_oModel, 'generateBackupCodes', array('123456'));
$this->callMethod($this->_oModel, 'generateBackupCodes', ['123456']);
}
/**
@ -127,7 +127,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
$oBackupCodeMock->expects($this->once())->method('save')->willReturn(true);
$aBackupCodeArray = [
$oBackupCodeMock
$oBackupCodeMock,
];
/** @var d3backupcodelist|MockObject $oModelMock */
@ -178,7 +178,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'getOne',
'quoteIdentifier',
'quote'
'quote',
])
->disableOriginalConstructor()
->getMock();
@ -191,7 +191,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'd3GetDb',
'getBaseObject',
'd3GetUser'
'd3GetUser',
])
->getMock();
$oModelMock->method('d3GetDb')->willReturn($oDbMock);
@ -201,7 +201,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
$this->_oModel = $oModelMock;
$this->assertTrue(
$this->callMethod($this->_oModel, 'verify', array('123456'))
$this->callMethod($this->_oModel, 'verify', ['123456'])
);
}
@ -242,7 +242,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'd3GetDb',
'getBaseObject',
'd3GetUser'
'd3GetUser',
])
->getMock();
$oModelMock->method('d3GetDb')->willReturn($oDbMock);
@ -252,7 +252,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
$this->_oModel = $oModelMock;
$this->assertFalse(
$this->callMethod($this->_oModel, 'verify', array('123456'))
$this->callMethod($this->_oModel, 'verify', ['123456'])
);
}
@ -294,7 +294,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
$oBackupCodeMock->expects($this->once())->method('delete')->willReturn(true);
$aBackupCodeArray = [
$oBackupCodeMock
$oBackupCodeMock,
];
/** @var d3backupcodelist|MockObject $oModelMock */
@ -302,7 +302,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'getArray',
'selectString',
'd3GetDb'
'd3GetDb',
])
->getMock();
$oModelMock->expects($this->once())->method('getArray')->willReturn($aBackupCodeArray);
@ -345,7 +345,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'getArray',
'selectString',
'd3GetDb'
'd3GetDb',
])
->getMock();
$oModelMock->expects($this->once())->method('getArray')->willReturn($aBackupCodeArray);
@ -369,7 +369,7 @@ class d3backupcodelistTest extends d3TotpUnitTestCase
->onlyMethods([
'getOne',
'quoteIdentifier',
'quote'
'quote',
])
->disableOriginalConstructor()
->getMock();

View File

@ -85,7 +85,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'd3GetDb',
'load'
'load',
])
->getMock();
$oModelMock->method('d3GetDb')->willReturn($oDbMock);
@ -108,7 +108,7 @@ class d3totpTest extends d3TotpUnitTestCase
->disableOriginalConstructor()
->onlyMethods([
'getOne',
'quote'
'quote',
])->getMock();
$oDbMock->expects($this->exactly(2))->method('getOne')->willReturnOnConsecutiveCalls(true, true);
$oDbMock->method('quote')->willReturn(true);
@ -117,7 +117,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'd3GetDb',
'load'
'load',
])
->getMock();
$oModelMock->method('d3GetDb')->willReturn($oDbMock);
@ -205,7 +205,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oDbMock = $this->getMockBuilder(Database::class)
->onlyMethods([
'getOne',
'quote'
'quote',
])
->disableOriginalConstructor()
->getMock();
@ -221,7 +221,7 @@ class d3totpTest extends d3TotpUnitTestCase
$this->_oModel = $oModelMock;
$this->assertTrue(
$this->callMethod($this->_oModel, 'checkIfAlreadyExist', array('testUserId'))
$this->callMethod($this->_oModel, 'checkIfAlreadyExist', ['testUserId'])
);
}
@ -430,7 +430,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getFieldData',
'decrypt'
'decrypt',
])
->getMock();
$oModelMock->method('getFieldData')->willReturn('seed');
@ -455,7 +455,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getFieldData',
'decrypt'
'decrypt',
])
->getMock();
$oModelMock->method('getFieldData')->willReturn(null);
@ -479,7 +479,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getFieldData',
'decrypt'
'decrypt',
])
->getMock();
$oModelMock->method('getFieldData')->willReturn('seed');
@ -529,7 +529,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getUser',
'getSavedSecret'
'getSavedSecret',
])
->getMock();
$oModelMock->method('getUser')->willReturn($oUserMock);
@ -564,7 +564,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getUser',
'getSavedSecret'
'getSavedSecret',
])
->getMock();
$oModelMock->method('getUser')->willReturn($oUserMock);
@ -720,7 +720,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getTotp',
'd3GetBackupCodeListObject'
'd3GetBackupCodeListObject',
])
->getMock();
$oModelMock->method('getTotp')->willReturn($oTotpMock);
@ -758,7 +758,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getTotp',
'd3GetBackupCodeListObject'
'd3GetBackupCodeListObject',
])
->getMock();
$oModelMock->method('getTotp')->willReturn($oTotpMock);
@ -794,7 +794,7 @@ class d3totpTest extends d3TotpUnitTestCase
$oModelMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'getTotp',
'd3GetBackupCodeListObject'
'd3GetBackupCodeListObject',
])
->getMock();
$oModelMock->method('getTotp')->willReturn($oTotpMock);
@ -907,7 +907,7 @@ class d3totpTest extends d3TotpUnitTestCase
->onlyMethods([
'd3GetBackupCodeListObject',
'getFieldData',
'canDelete'
'canDelete',
])
->getMock();
$oModelMock->method('d3GetBackupCodeListObject')->willReturn($oBackupCodeListMock);

View File

@ -77,7 +77,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
->onlyMethods([
'getUser',
'd3GetTotpObject',
'getParent'
'getParent',
])
->getMock();
$oControllerMock->method('getUser')->willReturn($oUser);
@ -102,7 +102,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oUserMock = $this->getMockBuilder(User::class)
->onlyMethods([
'logout',
'getId'
'getId',
])
->getMock();
$oUserMock->expects($this->never())->method('logout')->willReturn(false);
@ -118,7 +118,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->disableOriginalConstructor()
->getMock();
@ -130,7 +130,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
->onlyMethods([
'getUser',
'd3GetTotpObject',
'getParent'
'getParent',
])
->getMock();
$oControllerMock->method('getUser')->willReturn($oUserMock);
@ -171,7 +171,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->disableOriginalConstructor()
->getMock();
@ -183,7 +183,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
->onlyMethods([
'getUser',
'd3GetTotpObject',
'getParent'
'getParent',
])
->getMock();
$oControllerMock->method('getUser')->willReturn($oUserMock);
@ -233,7 +233,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'isNoTotpOrNoLogin',
'hasValidTotp',
'd3TotpRelogin',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(true);
@ -281,7 +281,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'hasValidTotp',
'd3TotpRelogin',
'd3GetUtilsView',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
@ -325,7 +325,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'hasValidTotp',
'd3TotpRelogin',
'd3GetUtilsView',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('isNoTotpOrNoLogin')->willReturn(false);
@ -389,7 +389,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(true);
$this->assertTrue(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -410,7 +410,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(false);
$this->assertTrue(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -431,7 +431,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('isActive')->willReturn(true);
$this->assertFalse(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -452,7 +452,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false);
$this->assertTrue(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}
@ -473,7 +473,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true);
$this->assertTrue(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}
@ -494,7 +494,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true);
$this->assertFalse(
$this->callMethod($this->_oController, 'hasValidTotp', array(null, $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', [null, $oTotpMock])
);
}
@ -515,7 +515,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false);
$this->assertFalse(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}
@ -544,7 +544,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
'd3GetSession',
'setUser',
'setLoginStatus',
'_afterLogin'
'_afterLogin',
])
->getMock();
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
@ -554,7 +554,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->callMethod($this->_oController, 'd3TotpRelogin', array($oUserMock, '123456'));
$this->callMethod($this->_oController, 'd3TotpRelogin', [$oUserMock, '123456']);
}
/**

View File

@ -60,7 +60,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->disableOriginalConstructor()
->getMock();
@ -71,7 +71,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oSessionMock = $this->getMockBuilder(Session::class)
->onlyMethods([
'getVariable',
'setVariable'
'setVariable',
])
->getMock();
$oSessionMock->method('getVariable')->will($this->onConsecutiveCalls(false, true));
@ -81,7 +81,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods([
'd3GetSession',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
@ -90,7 +90,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertSame('login.tpl', $this->callMethod($this->_oController, 'render'));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', array('request_totp')));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', ['request_totp']));
}
/**
@ -106,7 +106,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
->disableOriginalConstructor()
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->getMock();
$oTotpMock->expects($this->once())->method('isActive')->willReturn(false);
@ -126,7 +126,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods([
'd3GetSession',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
@ -135,7 +135,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertSame('login.tpl', $this->callMethod($this->_oController, 'render'));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', array('request_totp')));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', ['request_totp']));
}
/**
@ -150,7 +150,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->disableOriginalConstructor()
->getMock();
@ -171,7 +171,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods([
'd3GetSession',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
@ -180,7 +180,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertSame('login.tpl', $this->callMethod($this->_oController, 'render'));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', array('request_totp')));
$this->assertNotTrue($this->callMethod($this->_oController, 'getViewDataElement', ['request_totp']));
}
/**
@ -195,7 +195,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->disableOriginalConstructor()
->getMock();
@ -216,7 +216,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
->onlyMethods([
'd3GetSession',
'd3GetTotpObject'
'd3GetTotpObject',
])
->getMock();
$oControllerMock->method('d3GetSession')->willReturn($oSessionMock);
@ -225,7 +225,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertSame('login.tpl', $this->callMethod($this->_oController, 'render'));
$this->assertTrue($this->callMethod($this->_oController, 'getViewDataElement', array('request_totp')));
$this->assertTrue($this->callMethod($this->_oController, 'getViewDataElement', ['request_totp']));
}
/**
@ -301,7 +301,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
'd3GetTotpObject',
'isNoTotpOrNoLogin',
'hasValidTotp',
'hasLoginCredentials'
'hasLoginCredentials',
])
->getMock();
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -339,7 +339,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
{
return [
'no totp, no login credentials' => [false],
'no totp, given login credentials' => [true]
'no totp, given login credentials' => [true],
];
}
@ -374,7 +374,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
'd3GetTotpObject',
'isNoTotpOrNoLogin',
'hasValidTotp',
'd3GetUtilsView'
'd3GetUtilsView',
])
->getMock();
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -423,7 +423,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
'isNoTotpOrNoLogin',
'hasValidTotp',
'd3GetUtilsView',
'd3GetSession'
'd3GetSession',
])
->getMock();
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -522,7 +522,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertFalse(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -555,7 +555,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertFalse(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -588,7 +588,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$this->_oController = $oControllerMock;
$this->assertTrue(
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', array($oTotpMock))
$this->callMethod($this->_oController, 'isNoTotpOrNoLogin', [$oTotpMock])
);
}
@ -609,7 +609,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false);
$this->assertTrue(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}
@ -630,7 +630,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true);
$this->assertTrue(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}
@ -651,7 +651,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(true);
$this->assertFalse(
$this->callMethod($this->_oController, 'hasValidTotp', array(null, $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', [null, $oTotpMock])
);
}
@ -672,7 +672,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
$oTotpMock->method('verify')->willReturn(false);
$this->assertFalse(
$this->callMethod($this->_oController, 'hasValidTotp', array('123456', $oTotpMock))
$this->callMethod($this->_oController, 'hasValidTotp', ['123456', $oTotpMock])
);
}

View File

@ -70,7 +70,7 @@ trait d3_totp_getUserTestTrait
->disableOriginalConstructor()
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->getMock();
$oTotpMock->method('isActive')->willReturn(false);
@ -80,7 +80,7 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([
'd3GetTotpObject',
'd3GetSessionObject'
'd3GetSessionObject',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -121,7 +121,7 @@ trait d3_totp_getUserTestTrait
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->getMock();
$oTotpMock->method('isActive')->willReturn(true);
@ -131,7 +131,7 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([
'd3GetTotpObject',
'd3GetSessionObject'
'd3GetSessionObject',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -173,7 +173,7 @@ trait d3_totp_getUserTestTrait
->disableOriginalConstructor()
->onlyMethods([
'isActive',
'loadByUserId'
'loadByUserId',
])
->getMock();
$oTotpMock->method('isActive')->willReturn(true);
@ -183,7 +183,7 @@ trait d3_totp_getUserTestTrait
$oControllerMock = $this->getMockBuilder($this->sControllerClass)
->onlyMethods([
'd3GetTotpObject',
'd3GetSessionObject'
'd3GetSessionObject',
])
->getMock();
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);

View File

@ -128,7 +128,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'loadByUserId',
'isActive'
'isActive',
])
->disableOriginalConstructor()
->getMock();
@ -139,7 +139,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
$oCoreMock = $this->getMockBuilder(Utils::class)
->onlyMethods([
'd3GetTotpObject',
'fetchRightsForUser'
'fetchRightsForUser',
])
->getMock();
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -171,7 +171,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
$oTotpMock = $this->getMockBuilder(d3totp::class)
->onlyMethods([
'loadByUserId',
'isActive'
'isActive',
])
->disableOriginalConstructor()
->getMock();
@ -184,7 +184,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
'd3GetTotpObject',
'd3GetSessionObject',
'fetchRightsForUser',
'redirect'
'redirect',
])
->getMock();
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -237,7 +237,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
'd3GetTotpObject',
'd3GetSessionObject',
'fetchRightsForUser',
'redirect'
'redirect',
])
->getMock();
$oCoreMock->method('d3GetTotpObject')->willReturn($oTotpMock);
@ -366,7 +366,7 @@ class d3_totp_utilsTest extends d3TotpUnitTestCase
{
return [
[true],
[false]
[false],
];
}
}