diff --git a/lam/tests/design/designExamples.php b/lam/tests/design/designExamples.php
index 335664d9b..782c5228d 100644
--- a/lam/tests/design/designExamples.php
+++ b/lam/tests/design/designExamples.php
@@ -51,17 +51,17 @@ $row->addField(new htmlButton('name1', 'Click me'));
$row->addLabel(new htmlOutputText('Primary'));
$primaryButton = new htmlButton('name2', 'Click me');
-$primaryButton->setCSSClasses(array('lam-primary'));
+$primaryButton->setCSSClasses(['lam-primary']);
$row->addField($primaryButton);
$row->addLabel(new htmlOutputText('Secondary'));
$primaryButton = new htmlButton('name2a', 'Click me');
-$primaryButton->setCSSClasses(array('lam-secondary'));
+$primaryButton->setCSSClasses(['lam-secondary']);
$row->addField($primaryButton);
$row->addLabel(new htmlOutputText('Danger'));
$primaryButton = new htmlButton('name3', 'Click me');
-$primaryButton->setCSSClasses(array('lam-danger'));
+$primaryButton->setCSSClasses(['lam-danger']);
$row->addField($primaryButton);
$row->addLabel(new htmlOutputText('Disabled'));
@@ -70,10 +70,10 @@ $buttonDisabled->setIsEnabled(false);
$row->addField($buttonDisabled);
$row->add(new htmlSubTitle('Tables'));
-$tableTitles = array('text 1', 'text 2', 'text 3', 'text 4', 'text 5');
-$tableData = array();
+$tableTitles = ['text 1', 'text 2', 'text 3', 'text 4', 'text 5'];
+$tableData = [];
for ($rowNumber = 0; $rowNumber < 10; $rowNumber++) {
- $tableRow = array();
+ $tableRow = [];
for ($column = 0; $column < 5; $column++) {
$tableRow[] = new htmlOutputText('value' . $column);
}
@@ -85,7 +85,7 @@ $row->add($table);
$row->addVerticalSpacer('2rem');
$row->add(new htmlOutputText('Account list'));
$table = new htmlResponsiveTable($tableTitles, $tableData);
-$table->setCSSClasses(array('accountlist'));
+$table->setCSSClasses(['accountlist']);
$row->add($table);
$row->add(new htmlSubTitle('Input fields'));
@@ -95,7 +95,7 @@ $row->addField(new htmlInputField('text1', 'Some text'));
$row->addLabel(new htmlOutputText('Autocomplete'));
$autocompleteInput = new htmlInputField('text1a', 'Some text');
-$autocompleteInput->enableAutocompletion(array('Some text', 'Some text2', 'Some text3', 'Some text4'));
+$autocompleteInput->enableAutocompletion(['Some text', 'Some text2', 'Some text3', 'Some text4']);
$row->addField($autocompleteInput);
$row->addLabel(new htmlOutputText('Disabled'));
@@ -132,10 +132,10 @@ $checkRow2->add($checkboxDisabled);
$row->add($checkRow2);
$row->addLabel(new htmlOutputText('Default'));
-$row->addField(new htmlRadio('radio1', array('label1' => 'value', 'label2' => 'value2'), 'value'));
+$row->addField(new htmlRadio('radio1', ['label1' => 'value', 'label2' => 'value2'], 'value'));
$row->addLabel(new htmlOutputText('Disabled'));
-$radioDisabled = new htmlRadio('radio2', array('label1' => 'value', 'label2' => 'value2'), 'value');
+$radioDisabled = new htmlRadio('radio2', ['label1' => 'value', 'label2' => 'value2'], 'value');
$radioDisabled->setIsEnabled(false);
$row->addField($radioDisabled);
@@ -156,20 +156,20 @@ $colorDisabled->setIsEnabled(false);
$row->addField($colorDisabled);
$row->addLabel(new htmlOutputText('Default select'));
-$row->addField(new htmlSelect('select1', array(1, 2, 3), array(2)));
+$row->addField(new htmlSelect('select1', [1, 2, 3], [2]));
$row->addLabel(new htmlOutputText('Disabled select'));
-$selectDisabled = new htmlSelect('select2', array(1, 2, 3), array(2));
+$selectDisabled = new htmlSelect('select2', [1, 2, 3], [2]);
$selectDisabled->setIsEnabled(false);
$row->addField($selectDisabled);
$row->addLabel(new htmlOutputText('Default multiselect'));
-$multiSelect1 = new htmlSelect('select1', array("1", "2", "3"), array("1", "3"), 5);
+$multiSelect1 = new htmlSelect('select1', ["1", "2", "3"], ["1", "3"], 5);
$multiSelect1->setMultiSelect(true);
$row->addField($multiSelect1);
$row->addLabel(new htmlOutputText('Disabled multiselect'));
-$multiSelect2 = new htmlSelect('select2', array("1", "2", "3"), array("1", "3"), 5);
+$multiSelect2 = new htmlSelect('select2', ["1", "2", "3"], ["1", "3"], 5);
$multiSelect2->setIsEnabled(false);
$multiSelect2->setMultiSelect(true);
$row->addField($multiSelect2);
@@ -177,12 +177,12 @@ $row->addField($multiSelect2);
$row->add(new htmlSpacer(null, '5rem'));
$row->addLabel(new htmlOutputText('Default select filter'));
-$defaultSelectElements = array();
+$defaultSelectElements = [];
for ($i = 0; $i < 1000; $i++) {
$text = str_pad($i, 4, '0', STR_PAD_LEFT);
$defaultSelectElements['Text ' . $text] = $text;
}
-$row->addField(new htmlSelect('selectWithFilter', $defaultSelectElements, array('0002')));
+$row->addField(new htmlSelect('selectWithFilter', $defaultSelectElements, ['0002']));
$row->addLabel(new htmlOutputText('Filter'));
$selectFilter = new htmlInputField('selectFilter');
$selectFilter->filterSelectBox('selectWithFilter');
@@ -191,12 +191,12 @@ $row->addField($selectFilter);
$row->add(new htmlSpacer(null, '5rem'));
$row->addLabel(new htmlOutputText('Default multiselect filter'));
-$defaultScrollElements = array();
+$defaultScrollElements = [];
for ($i = 0; $i < 1000; $i++) {
$text = str_pad($i, 4, '0', STR_PAD_LEFT);
$defaultScrollElements['Text ' . $text] = $text;
}
-$scrollSelect = new htmlSelect('scrollSelect', $defaultScrollElements, array("0001", "0003", "0999"), 10);
+$scrollSelect = new htmlSelect('scrollSelect', $defaultScrollElements, ["0001", "0003", "0999"], 10);
$scrollSelect->setHasDescriptiveElements(true);
$scrollSelect->setMultiSelect(true);
$row->addField($scrollSelect);
@@ -208,12 +208,12 @@ $row->addField($scrollFilter);
$row->add(new htmlSpacer(null, '5rem'));
$row->addLabel(new htmlOutputText('Dynamic multiselect filter'));
-$dynamicScrollElements = array();
+$dynamicScrollElements = [];
for ($i = 0; $i < 100000; $i++) {
$text = str_pad($i, 6, '0', STR_PAD_LEFT);
$dynamicScrollElements['Text ' . $text] = $text;
}
-$multiSelect3 = new htmlSelect('dynamicSelect', $dynamicScrollElements, array("000001", "000003", "099999"), 10);
+$multiSelect3 = new htmlSelect('dynamicSelect', $dynamicScrollElements, ["000001", "000003", "099999"], 10);
$multiSelect3->setHasDescriptiveElements(true);
$multiSelect3->setMultiSelect(true);
$multiSelect3->enableDynamicScrolling();
@@ -257,7 +257,7 @@ $row->add(new htmlSpacer(null, '5rem'));
$row->add(new htmlSubTitle('Accordion'));
-$accordionElementsSingle = array();
+$accordionElementsSingle = [];
$accordionElementsSingleContent1 = new htmlResponsiveRow();
$accordionElementsSingleContent1->add(new htmlResponsiveInputField('Input 1', 'acc1i1'));
$accordionElementsSingleContent1->add(new htmlResponsiveInputField('Input 2', 'acc1i2'));
@@ -267,7 +267,7 @@ $row->add(new htmlAccordion('acc_single', $accordionElementsSingle));
$row->add(new htmlSpacer(null, '5rem'));
-$accordionElementsSingleClosed = array();
+$accordionElementsSingleClosed = [];
$accordionElementsSingleContentClosed = new htmlResponsiveRow();
$accordionElementsSingleContentClosed->add(new htmlResponsiveInputField('Input 1', 'acc1ai1'));
$accordionElementsSingleContentClosed->add(new htmlResponsiveInputField('Input 2', 'acc1ai2'));
@@ -277,7 +277,7 @@ $row->add(new htmlAccordion('acc_singleClosed', $accordionElementsSingleClosed,
$row->add(new htmlSpacer(null, '5rem'));
-$accordionElementsMulti = array();
+$accordionElementsMulti = [];
for ($i = 0; $i < 5; $i++) {
$accordionElementsContent = new htmlResponsiveRow();
$accordionElementsContent->add(new htmlResponsiveInputField('Input 1', 'acc1i1' . $i));
@@ -291,33 +291,33 @@ $row->add(new htmlSpacer(null, '5rem'));
$row->add(new htmlSubTitle('Sortable list'));
-$sortableList1 = new htmlSortableList(array(
+$sortableList1 = new htmlSortableList([
'text 1',
'text 2',
'text 3',
'text 4',
'text 5',
-), 'sortableList1');
+], 'sortableList1');
$sortableList1->setCSSClasses(array('module-list'));
$row->add($sortableList1);
$row->add(new htmlSpacer(null, '2rem'));
-$listElements = array();
+$listElements = [];
for ($i = 0; $i < 8; $i++) {
$el = new htmlTable('100%');
$image = new htmlImage('../../graphics/tux.svg');
- $image->setCSSClasses(array('size16', 'margin-right5-mobile-only'));
+ $image->setCSSClasses(['size16', 'margin-right5-mobile-only']);
$el->addElement($image);
$el->addElement(new htmlOutputText("Text " . $i));
$image2 = new htmlImage('../../graphics/del.svg');
- $image2->setCSSClasses(array('size16', 'margin-right5-mobile-only'));
+ $image2->setCSSClasses(['size16', 'margin-right5-mobile-only']);
$image2->alignment = htmlElement::ALIGN_RIGHT;
$el->addElement($image2);
$listElements[] = $el;
}
$sortableList2 = new htmlSortableList($listElements, 'sortableList2');
-$sortableList2->setCSSClasses(array('module-list'));
+$sortableList2->setCSSClasses(['module-list']);
$row->add($sortableList2);
$row->add(new htmlSubTitle('Alert'));
@@ -344,7 +344,7 @@ $row->add(new htmlSpacer(null, '20rem'));
$form = new htmlForm('formname', 'designExamples.php', $row);
-parseHtml(null, $form, array(), false, 'user');
+parseHtml(null, $form, [], false, 'user');
?>
diff --git a/lam/tests/lib/2factorTest.php b/lam/tests/lib/2factorTest.php
index eaec76dae..325063e5a 100644
--- a/lam/tests/lib/2factorTest.php
+++ b/lam/tests/lib/2factorTest.php
@@ -36,7 +36,7 @@ require_once 'lam/lib/2factor.inc';
*/
class TwoFactorTest extends TestCase {
- const USER_NAME = 'uid=test,dc=example,dc=com';
+ public const USER_NAME = 'uid=test,dc=example,dc=com';
private ?LAMConfig $serverProfile = null;
diff --git a/lam/tests/lib/AccountTest.php b/lam/tests/lib/AccountTest.php
index cf817d3d6..57295d394 100644
--- a/lam/tests/lib/AccountTest.php
+++ b/lam/tests/lib/AccountTest.php
@@ -2,7 +2,7 @@
use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2018 - 2021 Roland Gruber
+ Copyright (C) 2018 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,8 +51,8 @@ class AccountTest extends TestCase {
$this->assertEquals(7215, unformatShortFormatToSeconds('2h15s'));
$this->assertEquals(172815, unformatShortFormatToSeconds('2d15s'));
$this->assertEquals(173700, unformatShortFormatToSeconds('2d15m'));
- $this->assertEquals(1209615, unformatShortFormatToSeconds('2w15s'));
- $this->assertEquals(95817615, unformatShortFormatToSeconds('3y2w15s'));
+ $this->assertEquals(1_209_615, unformatShortFormatToSeconds('2w15s'));
+ $this->assertEquals(95_817_615, unformatShortFormatToSeconds('3y2w15s'));
}
/**
@@ -83,8 +83,8 @@ class AccountTest extends TestCase {
$this->assertEquals('2h15s', formatSecondsToShortFormat(7215));
$this->assertEquals('2d15s', formatSecondsToShortFormat(172815));
$this->assertEquals('2d15m', formatSecondsToShortFormat(173700));
- $this->assertEquals('2w15s', formatSecondsToShortFormat(1209615));
- $this->assertEquals('3y2w15s', formatSecondsToShortFormat(95817615));
+ $this->assertEquals('2w15s', formatSecondsToShortFormat(1_209_615));
+ $this->assertEquals('3y2w15s', formatSecondsToShortFormat(95_817_615));
}
/**
@@ -199,7 +199,7 @@ class AccountTest extends TestCase {
*/
function testPwdHash() {
$testPassword = '1234556';
- $types = array('ARGON2ID', 'SSHA', 'SHA', 'SMD5', 'MD5', 'CRYPT', 'CRYPT-SHA512');
+ $types = ['ARGON2ID', 'SSHA', 'SHA', 'SMD5', 'MD5', 'CRYPT', 'CRYPT-SHA512'];
foreach ($types as $type) {
$hash = pwd_hash($testPassword, true, $type);
$type = getHashType($hash);
@@ -244,7 +244,7 @@ class AccountTest extends TestCase {
function testGenerateRandomPassword() {
global $_SESSION;
- $_SESSION = array('cfgMain' => new LAMCfgMain());
+ $_SESSION = ['cfgMain' => new LAMCfgMain()];
$this->assertEquals(20, strlen(generateRandomPassword(20)));
}
diff --git a/lam/tests/lib/BaseModuleTest.php b/lam/tests/lib/BaseModuleTest.php
index 9874b1fe4..365bd6230 100644
--- a/lam/tests/lib/BaseModuleTest.php
+++ b/lam/tests/lib/BaseModuleTest.php
@@ -2,7 +2,7 @@
use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2019 Roland Gruber
+ Copyright (C) 2019 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,233 +34,243 @@ class BaseModuleTest extends TestCase {
}
function test_check_profileOptions_ext_preg() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
+ 'error_message' => ['ERROR', 'error1']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('10'),
- );
+ $options = [
+ 'test_val1' => ['10'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
$this->assertEmpty($errors, print_r($errors, true));
}
function test_check_profileOptions_ext_preg_fail() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
+ 'error_message' => ['ERROR', 'error1']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('a'),
- );
+ $options = [
+ 'test_val1' => ['a'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
- $this->assertEquals(array(array('ERROR', 'error1')), $errors);
+ $this->assertEquals([['ERROR', 'error1']], $errors);
}
function test_check_profileOptions_regex() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_reg1'] = array(
+ $meta['profile_checks']['test_reg1'] = [
'type' => 'regex',
'regex' => 'ab+a',
- 'error_message' => array('ERROR', 'error1'));
+ 'error_message' => ['ERROR', 'error1']];
$module->setMeta($meta);
- $options = array(
- 'test_reg1' => array('abbba'),
- );
+ $options = [
+ 'test_reg1' => ['abbba'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
$this->assertEmpty($errors, print_r($errors, true));
}
function test_check_profileOptions_regex_fail() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_reg1'] = array(
+ $meta['profile_checks']['test_reg1'] = [
'type' => 'regex',
'regex' => 'ab+a',
- 'error_message' => array('ERROR', 'error1'));
+ 'error_message' => ['ERROR', 'error1']];
$module->setMeta($meta);
- $options = array(
- 'test_reg1' => array('aCa'),
- );
+ $options = [
+ 'test_reg1' => ['aCa'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
- $this->assertEquals(array(array('ERROR', 'error1')), $errors);
+ $this->assertEquals([['ERROR', 'error1']], $errors);
}
function test_check_profileOptions_cmp() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greater',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('10'),
- 'test_val2' => array('20'),
- );
+ $options = [
+ 'test_val1' => ['10'],
+ 'test_val2' => ['20'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
$this->assertEmpty($errors, print_r($errors, true));
}
function test_check_profileOptions_cmp_fail_equal() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greater',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('10'),
- 'test_val2' => array('10'),
- );
+ $options = [
+ 'test_val1' => ['10'],
+ 'test_val2' => ['10'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
- $this->assertEquals(array(array('ERROR', 'errorCMP')), $errors);
+ $this->assertEquals([['ERROR', 'errorCMP']], $errors);
}
function test_check_profileOptions_cmp_fail_smaller() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greater',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('20'),
- 'test_val2' => array('10'),
- );
+ $options = [
+ 'test_val1' => ['20'],
+ 'test_val2' => ['10'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
- $this->assertEquals(array(array('ERROR', 'errorCMP')), $errors);
+ $this->assertEquals([['ERROR', 'errorCMP']], $errors);
}
function test_check_profileOptions_cmpEqual_greater() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greaterOrEqual',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('10'),
- 'test_val2' => array('20'),
- );
+ $options = [
+ 'test_val1' => ['10'],
+ 'test_val2' => ['20'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
$this->assertEmpty($errors, print_r($errors, true));
}
function test_check_profileOptions_cmpEqual_equal() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greaterOrEqual',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('10'),
- 'test_val2' => array('10'),
- );
+ $options = [
+ 'test_val1' => ['10'],
+ 'test_val2' => ['10'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
$this->assertEmpty($errors, print_r($errors, true));
}
function test_check_profileOptions_cmpEqual_fail() {
+ $meta = [];
$module = new baseModuleDummy('user');
- $meta['profile_checks']['test_val1'] = array(
+ $meta['profile_checks']['test_val1'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error1'));
- $meta['profile_checks']['test_val2'] = array(
+ 'error_message' => ['ERROR', 'error1']];
+ $meta['profile_checks']['test_val2'] = [
'type' => 'ext_preg',
'regex' => 'digit',
- 'error_message' => array('ERROR', 'error2'));
- $meta['profile_checks']['test_cmp'] = array(
+ 'error_message' => ['ERROR', 'error2']];
+ $meta['profile_checks']['test_cmp'] = [
'type' => 'int_greaterOrEqual',
'cmp_name1' => 'test_val2',
'cmp_name2' => 'test_val1',
- 'error_message' => array('ERROR', 'errorCMP'));
+ 'error_message' => ['ERROR', 'errorCMP']];
$module->setMeta($meta);
- $options = array(
- 'test_val1' => array('20'),
- 'test_val2' => array('10'),
- );
+ $options = [
+ 'test_val1' => ['20'],
+ 'test_val2' => ['10'],
+ ];
$errors = $module->check_profileOptions($options, 'user1');
- $this->assertEquals(array(array('ERROR', 'errorCMP')), $errors);
+ $this->assertEquals([['ERROR', 'errorCMP']], $errors);
}
}
diff --git a/lam/tests/lib/ConfigDataExporterTest.php b/lam/tests/lib/ConfigDataExporterTest.php
index deb924f7a..78a8124ed 100644
--- a/lam/tests/lib/ConfigDataExporterTest.php
+++ b/lam/tests/lib/ConfigDataExporterTest.php
@@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2020 - 2021 Roland Gruber
+ Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,46 +32,48 @@ include_once __DIR__ . '/../../lib/persistence.inc';
class ConfigDataExporterTest extends TestCase {
public function testExportAsJson() {
- $mainData = array(
+ $mainData = [
'confMainKey1' => 'val',
'confMainKey2' => 4,
'confMainKey3' => '',
- );
- $profileData = array(
- 'profile1' => array('ServerURL' => 'myserver'),
- 'profile2' => array('ServerURL' => 'myserver2'),
- );
- $accountProfileData = array(
- 'profile1' => array('user' => array('default' => array('key' => 'value'))),
- 'profile2' => array(
- 'user' => array('default' => array('key' => 'value')),
- 'group' => array('default' => array('key' => 'value')),
- ),
- );
- $accountProfileTemplateData = array(
- 'user' => array('default' => array('key' => 'value')),
- 'group' => array('default' => array('key' => 'value')),
- );
- $pdfData = array(
- 'profile1' => array('structures' => array(
- 'user' => array(
- 'default' => array('key' => 'value'))
- )),
- 'profile2' => array('structures' => array(
- 'user' => array('default' => array('key' => 'value')),
- 'group' => array('default' => array('key' => 'value')),
- )),
- );
- $pdfTemplateData = array(
- 'user' => array('default' => array('key' => 'value')),
- 'group' => array('default' => array('key' => 'value')),
- );
- $selfServiceData = array(
- 'profile1' => array('key' => 'value'),
- 'profile2' => array('key' => 'value'),
- );
- $webauthn = array();
- $expectedJson = json_encode(array(
+ ];
+ $profileData = [
+ 'profile1' => ['ServerURL' => 'myserver'],
+ 'profile2' => ['ServerURL' => 'myserver2'],
+ ];
+ $accountProfileData = [
+ 'profile1' => ['user' => ['default' => ['key' => 'value']]],
+ 'profile2' => ['user' => ['default' => ['key' => 'value']], 'group' => ['default' => ['key' => 'value']]],
+ ];
+ $accountProfileTemplateData = [
+ 'user' => ['default' => ['key' => 'value']],
+ 'group' => ['default' => ['key' => 'value']],
+ ];
+ $pdfData = [
+ 'profile1' => [
+ 'structures' => [
+ 'user' => [
+ 'default' => ['key' => 'value']
+ ]
+ ]
+ ],
+ 'profile2' => [
+ 'structures' => [
+ 'user' => ['default' => ['key' => 'value']],
+ 'group' => ['default' => ['key' => 'value']],
+ ]
+ ],
+ ];
+ $pdfTemplateData = [
+ 'user' => ['default' => ['key' => 'value']],
+ 'group' => ['default' => ['key' => 'value']],
+ ];
+ $selfServiceData = [
+ 'profile1' => ['key' => 'value'],
+ 'profile2' => ['key' => 'value'],
+ ];
+ $webauthn = [];
+ $expectedJson = json_encode([
'mainConfig' => $mainData,
'certificates' => 'certs',
'serverProfiles' => $profileData,
@@ -81,14 +83,14 @@ class ConfigDataExporterTest extends TestCase {
'pdfProfileTemplates' => $pdfTemplateData,
'selfServiceProfiles' => $selfServiceData,
'webauthn' => $webauthn,
- 'cronJobs' => array()
- ));
+ 'cronJobs' => []
+ ]);
$exporter = $this->getMockBuilder('\LAM\PERSISTENCE\ConfigDataExporter')
- ->setMethods(array('_getMainConfigData', '_getCertificates', '_getServerProfiles',
+ ->setMethods(['_getMainConfigData', '_getCertificates', '_getServerProfiles',
'_getAccountProfiles', '_getAccountProfileTemplates', '_getPdfProfiles',
'_getPdfProfileTemplates', '_getSelfServiceProfiles', '_getWebauthn',
- '_getCronJobData'))
+ '_getCronJobData'])
->getMock();
$exporter->method('_getMainConfigData')->willReturn($mainData);
$exporter->method('_getCertificates')->willReturn('certs');
@@ -99,7 +101,7 @@ class ConfigDataExporterTest extends TestCase {
$exporter->method('_getPdfProfileTemplates')->willReturn($pdfTemplateData);
$exporter->method('_getSelfServiceProfiles')->willReturn($selfServiceData);
$exporter->method('_getWebauthn')->willReturn($webauthn);
- $exporter->method('_getCronJobData')->willReturn(array());
+ $exporter->method('_getCronJobData')->willReturn([]);
$json = $exporter->exportAsJson();
diff --git a/lam/tests/lib/ImporterTest.php b/lam/tests/lib/ImporterTest.php
index a2a0278ab..d42b407a1 100644
--- a/lam/tests/lib/ImporterTest.php
+++ b/lam/tests/lib/ImporterTest.php
@@ -11,7 +11,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2018 - 2021 Roland Gruber
+ Copyright (C) 2018 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,11 +42,11 @@ class ImporterTest extends TestCase {
* No LDIF at all.
*/
public function testCompletelyInvalid() {
- $lines = array(
+ $lines = [
"this is no LDIF"
- );
+ ];
- $this->expectException(LAMException::class, 'this is no LDIF');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -56,11 +56,11 @@ class ImporterTest extends TestCase {
* Wrong format version.
*/
public function testWrongVersion() {
- $lines = array(
+ $lines = [
"version: 3"
- );
+ ];
- $this->expectException(LAMException::class, 'version: 3');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -70,11 +70,11 @@ class ImporterTest extends TestCase {
* Multiple versions.
*/
public function testMultipleVersions() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"version: 1"
- );
+ ];
$this->expectException(LAMException::class);
@@ -86,10 +86,10 @@ class ImporterTest extends TestCase {
* Data after version.
*/
public function testDataAfterVersion() {
- $lines = array(
+ $lines = [
"version: 1",
"some: data"
- );
+ ];
$this->expectException(LAMException::class);
@@ -101,13 +101,13 @@ class ImporterTest extends TestCase {
* DN line without any data.
*/
public function testDnNoData() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com"
- );
+ ];
- $this->expectException(LAMException::class, 'dn: uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -117,13 +117,13 @@ class ImporterTest extends TestCase {
* One complete entry.
*/
public function testSingleFullEntry() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"objectClass: inetOrgPerson",
"uid: test",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
@@ -134,15 +134,15 @@ class ImporterTest extends TestCase {
* Change entry with invalid changetype.
*/
public function testChangeInvalidType() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: invalid",
"uid: test",
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com - changetype: invalid');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -152,34 +152,34 @@ class ImporterTest extends TestCase {
* Change entry with add changetype.
*/
public function testChangeAdd() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: add",
"uid: test",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(AddEntryTask::class, get_class($task));
+ $this->assertEquals(AddEntryTask::class, $task::class);
}
/**
* Change entry with modrdn changetype and invalid options.
*/
public function testChangeModRdnInvalidData() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: modrdn",
"uid: test",
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -189,16 +189,16 @@ class ImporterTest extends TestCase {
* Change entry with modrdn changetype and invalid deleteoldrdn.
*/
public function testChangeModRdnInvalidDeleteoldrdn() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: modrdn",
"newrdn: uid1=test",
"deleteoldrdn: x",
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -208,35 +208,35 @@ class ImporterTest extends TestCase {
* Change entry with modrdn changetype.
*/
public function testChangeModRdn() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: modrdn",
"newrdn: uid1=test",
"deleteoldrdn: 0",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(RenameEntryTask::class, get_class($task));
+ $this->assertEquals(RenameEntryTask::class, $task::class);
}
/**
* Change entry with delete changetype with extra line.
*/
public function testChangeDeleteInvalid() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: delete",
"uid: test",
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -246,33 +246,33 @@ class ImporterTest extends TestCase {
* Change entry with delete changetype.
*/
public function testChangeDelete() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: delete",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(DeleteEntryTask::class, get_class($task));
+ $this->assertEquals(DeleteEntryTask::class, $task::class);
}
/**
* Change entry with modify changetype with invalid operation.
*/
public function testChangeModifyInvalid() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: modify",
"invalid: test",
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -282,7 +282,7 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and add operation.
*/
public function testChangeModifyAddInvalid() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
@@ -290,9 +290,9 @@ class ImporterTest extends TestCase {
"add: uid",
"uid: uid1",
"invalid: uid2"
- );
+ ];
- $this->expectException(LAMException::class, 'uid=test,dc=example,dc=com');
+ $this->expectException(LAMException::class);
$importer = new Importer();
$importer->getTasks($lines);
@@ -302,7 +302,7 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and add operation.
*/
public function testChangeModifyAdd() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
@@ -310,17 +310,17 @@ class ImporterTest extends TestCase {
"add: uid",
"uid: uid1",
"uid: uid2"
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(MultiTask::class, get_class($task));
+ $this->assertEquals(MultiTask::class, $task::class);
$subtasks = $task->getTasks();
$this->assertEquals(1, sizeof($subtasks));
$subTask = $subtasks[0];
- $this->assertEquals(AddAttributesTask::class, get_class($subTask));
+ $this->assertEquals(AddAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertEquals(1, sizeof($attributes));
@@ -333,7 +333,7 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and two add operations.
*/
public function testChangeModifyAddTwice() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
@@ -345,17 +345,17 @@ class ImporterTest extends TestCase {
"add: gn",
"gn: name1",
"gn: name2"
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(MultiTask::class, get_class($task));
+ $this->assertEquals(MultiTask::class, $task::class);
$subtasks = $task->getTasks();
$this->assertEquals(2, sizeof($subtasks));
$subTask = $subtasks[0];
- $this->assertEquals(AddAttributesTask::class, get_class($subTask));
+ $this->assertEquals(AddAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertEquals(1, sizeof($attributes));
@@ -363,7 +363,7 @@ class ImporterTest extends TestCase {
$this->assertTrue(in_array('uid1', $attributes['uid']));
$this->assertTrue(in_array('uid2', $attributes['uid']));
$subTask = $subtasks[1];
- $this->assertEquals(AddAttributesTask::class, get_class($subTask));
+ $this->assertEquals(AddAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertEquals(1, sizeof($attributes));
@@ -376,7 +376,7 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and delete operation.
*/
public function testChangeModifyDelete() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
@@ -384,17 +384,17 @@ class ImporterTest extends TestCase {
"delete: uid",
"uid: uid1",
"uid: uid2"
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(MultiTask::class, get_class($task));
+ $this->assertEquals(MultiTask::class, $task::class);
$subtasks = $task->getTasks();
$this->assertEquals(1, sizeof($subtasks));
$subTask = $subtasks[0];
- $this->assertEquals(DeleteAttributesTask::class, get_class($subTask));
+ $this->assertEquals(DeleteAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertEquals(1, sizeof($attributes));
@@ -407,23 +407,23 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and delete operation.
*/
public function testChangeModifyDeleteAll() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
"changetype: modify",
"delete: uid",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(MultiTask::class, get_class($task));
+ $this->assertEquals(MultiTask::class, $task::class);
$subtasks = $task->getTasks();
$this->assertEquals(1, sizeof($subtasks));
$subTask = $subtasks[0];
- $this->assertEquals(DeleteAttributesTask::class, get_class($subTask));
+ $this->assertEquals(DeleteAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertTrue(empty($attributes));
@@ -433,7 +433,7 @@ class ImporterTest extends TestCase {
* Change entry with modify changetype and replace operation.
*/
public function testChangeModifyReplace() {
- $lines = array(
+ $lines = [
"version: 1",
"",
"dn: uid=test,dc=example,dc=com",
@@ -441,17 +441,17 @@ class ImporterTest extends TestCase {
"replace: uid",
"uid: uid1",
"uid: uid2",
- );
+ ];
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$this->assertEquals(1, sizeof($tasks));
$task = $tasks[0];
- $this->assertEquals(MultiTask::class, get_class($task));
+ $this->assertEquals(MultiTask::class, $task::class);
$subtasks = $task->getTasks();
$this->assertEquals(1, sizeof($subtasks));
$subTask = $subtasks[0];
- $this->assertEquals(ReplaceAttributesTask::class, get_class($subTask));
+ $this->assertEquals(ReplaceAttributesTask::class, $subTask::class);
$this->assertEquals($subTask->getDn(), 'uid=test,dc=example,dc=com');
$attributes = $subTask->getAttributes();
$this->assertEquals(1, sizeof($attributes));
diff --git a/lam/tests/lib/LAMCfgMainTest.php b/lam/tests/lib/LAMCfgMainTest.php
index e7eddbfc1..4f0a51dd9 100644
--- a/lam/tests/lib/LAMCfgMainTest.php
+++ b/lam/tests/lib/LAMCfgMainTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2020 - 2021 Roland Gruber
+ Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ include_once __DIR__ . '/../../lib/config.inc';
class LAMCfgMainTest extends TestCase {
private $conf;
- private $file;
+ private string $file;
/**
* Prepares the environment before running a test.
@@ -82,7 +82,7 @@ class LAMCfgMainTest extends TestCase {
$this->conf->licenseEmailTo = 'TO';
$this->conf->licenseEmailFrom = 'FROM';
$this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_ALL;
- $this->conf->setLicenseLines(array('123', '456'));
+ $this->conf->setLicenseLines(['123', '456']);
$this->conf->licenseEmailDateSent = $timestamp;
$this->conf->save();
@@ -93,7 +93,7 @@ class LAMCfgMainTest extends TestCase {
$this->assertEquals($timestamp, $this->conf->licenseEmailDateSent);
$this->assertTrue($this->conf->wasLicenseWarningSent($timestamp));
$this->assertEquals(LAMCfgMain::LICENSE_WARNING_ALL, $this->conf->licenseWarningType);
- $this->assertEquals(array('123', '456'), $this->conf->getLicenseLines());
+ $this->assertEquals(['123', '456'], $this->conf->getLicenseLines());
}
/**
@@ -142,7 +142,7 @@ class LAMCfgMainTest extends TestCase {
* Tests the import.
*/
public function testImportData() {
- $importData = array();
+ $importData = [];
$importData['passwordMinLower'] = 3;
$importData['sessionTimeout'] = 240;
$importData['logLevel'] = LOG_ERR;
@@ -163,7 +163,7 @@ class LAMCfgMainTest extends TestCase {
* Tests the import with invalid data.
*/
public function testImportData_invalid() {
- $importData = array();
+ $importData = [];
$importData['passwordMinLower'] = 3;
$importData['sessionTimeout'] = 240;
$importData['logLevel'] = LOG_ERR;
diff --git a/lam/tests/lib/LAMConfigTest.php b/lam/tests/lib/LAMConfigTest.php
index ba63542d9..01818ed66 100644
--- a/lam/tests/lib/LAMConfigTest.php
+++ b/lam/tests/lib/LAMConfigTest.php
@@ -30,7 +30,7 @@ include_once __DIR__ . '/../utils/configuration.inc';
*/
class LAMConfigTest extends TestCase {
- const FILE_NAME = 'd_lam_config_test';
+ public const FILE_NAME = 'd_lam_config_test';
/**
*
@@ -195,9 +195,9 @@ class LAMConfigTest extends TestCase {
$valInvalid = 'admin;';
$this->assertFalse($this->lAMConfig->set_Adminstring($valInvalid));
$this->lAMConfig->set_Adminstring($val);
- $this->assertEquals(array('cn=admin,dc=test', 'cn=admin2,dc=test'), $this->lAMConfig->get_Admins());
+ $this->assertEquals(['cn=admin,dc=test', 'cn=admin2,dc=test'], $this->lAMConfig->get_Admins());
$this->doSave();
- $this->assertEquals(array('cn=admin,dc=test', 'cn=admin2,dc=test'), $this->lAMConfig->get_Admins());
+ $this->assertEquals(['cn=admin,dc=test', 'cn=admin2,dc=test'], $this->lAMConfig->get_Admins());
}
/**
@@ -384,7 +384,7 @@ class LAMConfigTest extends TestCase {
public function testAccountModules() {
$scope = 'user';
$this->assertFalse($this->lAMConfig->set_AccountModules('abc', $scope));
- $val = array('posixAccount', 'shadowAccount');
+ $val = ['posixAccount', 'shadowAccount'];
$this->lAMConfig->set_AccountModules($val, $scope);
$this->assertEquals($val, $this->lAMConfig->get_AccountModules($scope));
$this->doSave();
@@ -396,7 +396,7 @@ class LAMConfigTest extends TestCase {
*/
public function testmoduleSettings() {
$this->assertFalse($this->lAMConfig->set_moduleSettings('abc'));
- $val = array('posixAccount_123' => array('123'), 'shadowAccount_123' => array('123'));
+ $val = ['posixAccount_123' => ['123'], 'shadowAccount_123' => ['123']];
$this->lAMConfig->set_moduleSettings($val);
$this->assertTrue(array_key_exists('posixAccount_123', $this->lAMConfig->get_moduleSettings()));
$this->assertTrue(array_key_exists('shadowAccount_123', $this->lAMConfig->get_moduleSettings()));
@@ -409,7 +409,7 @@ class LAMConfigTest extends TestCase {
* Tests LAMConfig->get_ActiveTypes() and LAMConfig->set_ActiveTypes()
*/
public function testActiveTypes() {
- $val = array('user', 'group');
+ $val = ['user', 'group'];
$this->lAMConfig->set_ActiveTypes($val);
$this->assertEquals($val, $this->lAMConfig->get_ActiveTypes());
$this->doSave();
@@ -421,7 +421,7 @@ class LAMConfigTest extends TestCase {
*/
public function testtypeSettings() {
$this->assertFalse($this->lAMConfig->set_typeSettings('abc'));
- $val = array('posixAccount_123' => '123', 'shadowAccount_123' => '123');
+ $val = ['posixAccount_123' => '123', 'shadowAccount_123' => '123'];
$this->lAMConfig->set_typeSettings($val);
$this->assertTrue(array_key_exists('posixAccount_123', $this->lAMConfig->get_typeSettings()));
$this->assertTrue(array_key_exists('shadowAccount_123', $this->lAMConfig->get_typeSettings()));
@@ -435,7 +435,7 @@ class LAMConfigTest extends TestCase {
*/
public function testGetToolSettings() {
$this->assertFalse($this->lAMConfig->setToolSettings('abc'));
- $val = array('user_123' => '123', 'group_123' => '123');
+ $val = ['user_123' => '123', 'group_123' => '123'];
$this->lAMConfig->setToolSettings($val);
$this->assertTrue(array_key_exists('user_123', $this->lAMConfig->getToolSettings()));
$this->assertTrue(array_key_exists('group_123', $this->lAMConfig->getToolSettings()));
@@ -448,10 +448,10 @@ class LAMConfigTest extends TestCase {
* Checks isToolActive().
*/
public function testIsToolActive() {
- $this->lAMConfig->setToolSettings(array(
+ $this->lAMConfig->setToolSettings([
'tool_hide_tool1' => 'true',
'tool_hide_tool2' => 'false',
- ));
+ ]);
$this->assertFalse($this->lAMConfig->isToolActive('tool1'));
$this->assertTrue($this->lAMConfig->isToolActive('tool2'));
$this->assertTrue($this->lAMConfig->isToolActive('tool3'));
@@ -857,7 +857,7 @@ class LAMConfigTest extends TestCase {
* Tests LAMConfig->setJobSettings() and LAMConfig->getJobSettings()
*/
public function testJobSettings() {
- $val = array('setting' => array('123'));
+ $val = ['setting' => ['123']];
$this->lAMConfig->setJobSettings($val);
$this->assertEquals($val, $this->lAMConfig->getJobSettings());
$this->doSave();
@@ -948,51 +948,51 @@ class LAMConfigTest extends TestCase {
public function testExportData() {
$this->lAMConfig->set_defaultLanguage('lang');
$this->lAMConfig->set_ServerURL('myserver');
- $this->lAMConfig->set_typeSettings(array('typetest' => '1'));
- $this->lAMConfig->set_moduleSettings(array('modtest' => '1'));
- $this->lAMConfig->setToolSettings(array('tooltest' => '1'));
- $this->lAMConfig->setJobSettings(array('jobtest' => '1'));
+ $this->lAMConfig->set_typeSettings(['typetest' => '1']);
+ $this->lAMConfig->set_moduleSettings(['modtest' => '1']);
+ $this->lAMConfig->setToolSettings(['tooltest' => '1']);
+ $this->lAMConfig->setJobSettings(['jobtest' => '1']);
$data = $this->lAMConfig->exportData();
$this->assertEquals('lang', $data['defaultLanguage']);
$this->assertEquals('myserver', $data['ServerURL']);
- $this->assertEquals(array('typetest' => '1'), $data['typeSettings']);
- $this->assertEquals(array('modtest' => '1'), $data['moduleSettings']);
- $this->assertEquals(array('tooltest' => '1'), $data['toolSettings']);
- $this->assertEquals(array('jobtest' => '1'), $data['jobSettings']);
+ $this->assertEquals(['typetest' => '1'], $data['typeSettings']);
+ $this->assertEquals(['modtest' => '1'], $data['moduleSettings']);
+ $this->assertEquals(['tooltest' => '1'], $data['toolSettings']);
+ $this->assertEquals(['jobtest' => '1'], $data['jobSettings']);
}
/**
* Tests the import.
*/
public function testImportData() {
- $importData = array();
+ $importData = [];
$importData['ServerURL'] = 'testserver';
$importData['defaultLanguage'] = 'de_DE.utf8';
- $importData['typeSettings'] = array('typetest' => 'value');
- $importData['toolSettings'] = array('tooltest' => 'value');
- $importData['moduleSettings'] = array('modtest' => 'value');
- $importData['jobSettings'] = array('jobtest' => 'value');
+ $importData['typeSettings'] = ['typetest' => 'value'];
+ $importData['toolSettings'] = ['tooltest' => 'value'];
+ $importData['moduleSettings'] = ['modtest' => 'value'];
+ $importData['jobSettings'] = ['jobtest' => 'value'];
$importData['IGNORE_ME'] = 'ignore';
$this->lAMConfig->importData($importData);
$this->assertEquals('testserver', $this->lAMConfig->get_ServerURL());
$this->assertEquals('de_DE.utf8', $this->lAMConfig->get_defaultLanguage());
- $this->assertEquals(array('typetest' => 'value'), $this->lAMConfig->get_typeSettings());
- $this->assertEquals(array('tooltest' => 'value'), $this->lAMConfig->getToolSettings());
- $this->assertEquals(array('modtest' => 'value'), $this->lAMConfig->get_moduleSettings());
- $this->assertEquals(array('jobtest' => 'value'), $this->lAMConfig->getJobSettings());
+ $this->assertEquals(['typetest' => 'value'], $this->lAMConfig->get_typeSettings());
+ $this->assertEquals(['tooltest' => 'value'], $this->lAMConfig->getToolSettings());
+ $this->assertEquals(['modtest' => 'value'], $this->lAMConfig->get_moduleSettings());
+ $this->assertEquals(['jobtest' => 'value'], $this->lAMConfig->getJobSettings());
}
/**
* Tests the import with invalid data.
*/
public function testImportData_invalid() {
- $importData = array();
+ $importData = [];
$importData['ServerURL'] = 'testserver';
- $importData['typeSettings'] = array('typetest' => 'value');
+ $importData['typeSettings'] = ['typetest' => 'value'];
$importData['defaultLanguage'] = new LAMLanguage('de_de', 'UTF-8', 'DE');
$this->expectException(LAMException::class);
diff --git a/lam/tests/lib/PdfStructTest.php b/lam/tests/lib/PdfStructTest.php
index 779ae7235..f6f16b198 100644
--- a/lam/tests/lib/PdfStructTest.php
+++ b/lam/tests/lib/PdfStructTest.php
@@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2017 - 2021 Roland Gruber
+ Copyright (C) 2017 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ class PdfStructTest extends TestCase {
public function testRead() {
$file = $this->getTestFileName('test.xml');
$fileHandle = fopen($file, "r");
- $originalXML = fread($fileHandle, 1000000);
+ $originalXML = fread($fileHandle, 1_000_000);
fclose($fileHandle);
$reader = new PDFStructureReader();
$structure = $reader->read($originalXML);
@@ -86,7 +86,7 @@ class PdfStructTest extends TestCase {
* @return string file name
*/
private function getTestFileName($file): string {
- return dirname(dirname(__FILE__)) . '/resources/pdf/' . $file;
+ return dirname(__DIR__) . '/resources/pdf/' . $file;
}
/**
@@ -97,7 +97,7 @@ class PdfStructTest extends TestCase {
$file = $this->getTestFileName('writer.xml');
// read input XML
$fileHandle = fopen($file, "r");
- $originalXML = fread($fileHandle, 1000000);
+ $originalXML = fread($fileHandle, 1_000_000);
fclose($fileHandle);
// read structure
$reader = new PDFStructureReader();
@@ -125,14 +125,14 @@ class PdfStructTest extends TestCase {
*/
public function testExportPDFEntrySection() {
$section = new PDFEntrySection('mytitle');
- $section->setEntries(array(new PDFSectionEntry('key1'), new PDFSectionEntry('key2')));
+ $section->setEntries([new PDFSectionEntry('key1'), new PDFSectionEntry('key2')]);
$data = $section->export();
- $expected = array(
+ $expected = [
'title' => 'mytitle',
- 'entries' => array('key1', 'key2')
- );
+ 'entries' => ['key1', 'key2']
+ ];
$this->assertEquals($expected, $data);
}
@@ -146,32 +146,32 @@ class PdfStructTest extends TestCase {
$structure->setLogo('somelogo');
$structure->setTitle('mytitle');
$entrySection = new PDFEntrySection('sometitle');
- $entrySection->setEntries(array(new PDFSectionEntry('key1')));
- $structure->setSections(array(
+ $entrySection->setEntries([new PDFSectionEntry('key1')]);
+ $structure->setSections([
new PDFTextSection('sometext'),
$entrySection
- ));
+ ]);
$data = $structure->export();
- $expected = array(
+ $expected = [
'title' => 'mytitle',
'foldingMarks' => PDFStructure::FOLDING_STANDARD,
'logo' => 'somelogo',
- 'sections' => array(
- array(
+ 'sections' => [
+ [
'type' => 'text',
'data' => 'sometext'
- ),
- array(
+ ],
+ [
'type' => 'entry',
- 'data' => array(
+ 'data' => [
'title' => 'sometitle',
- 'entries' => array('key1')
- )
- )
- )
- );
+ 'entries' => ['key1']
+ ]
+ ]
+ ]
+ ];
$this->assertEquals($expected, $data);
}
@@ -180,10 +180,10 @@ class PdfStructTest extends TestCase {
* Tests import in PDFEntrySection.
*/
public function testImportPDFEntrySection() {
- $data = array(
+ $data = [
'title' => 'mytitle',
- 'entries' => array('e1', 'e2')
- );
+ 'entries' => ['e1', 'e2']
+ ];
$section = new PDFEntrySection(null);
$section->import($data);
@@ -199,24 +199,24 @@ class PdfStructTest extends TestCase {
* Tests the import in PDFStructure.
*/
public function testImportPDFStructure() {
- $data = array(
+ $data = [
'title' => 'mytitle',
'foldingMarks' => PDFStructure::FOLDING_STANDARD,
'logo' => 'logo',
- 'sections' => array(
- array(
+ 'sections' => [
+ [
'type' => 'text',
'data' => 'textvalue'
- ),
- array(
+ ],
+ [
'type' => 'entry',
- 'data' => array(
+ 'data' => [
'title' => 'etitle',
- 'entries' => array('e1', 'e2')
- )
- ),
- )
- );
+ 'entries' => ['e1', 'e2']
+ ]
+ ],
+ ]
+ ];
$structure = new PDFStructure();
$structure->import($data);
diff --git a/lam/tests/lib/PublicKeyCredentialSourceRepositorySQLiteTest.php b/lam/tests/lib/PublicKeyCredentialSourceRepositorySQLiteTest.php
index b36ef14b1..cb39ca97a 100644
--- a/lam/tests/lib/PublicKeyCredentialSourceRepositorySQLiteTest.php
+++ b/lam/tests/lib/PublicKeyCredentialSourceRepositorySQLiteTest.php
@@ -11,7 +11,7 @@ use \Webauthn\TrustPath\CertificateTrustPath;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2019 - 2021 Roland Gruber
+ Copyright (C) 2019 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,9 +40,9 @@ require_once __DIR__ . '/../../lib/webauthn.inc';
class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|PublicKeyCredentialSourceRepositorySQLite
+ * @var PublicKeyCredentialSourceRepositorySQLite
*/
- private $database;
+ private PublicKeyCredentialSourceRepositorySQLiteTestDb $database;
protected function setUp(): void {
$this->database = new PublicKeyCredentialSourceRepositorySQLiteTestDb();
@@ -73,9 +73,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source1 = new PublicKeyCredentialSource(
"id1",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p1",
"uh1",
@@ -84,9 +84,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source2 = new PublicKeyCredentialSource(
"id2",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p2",
"uh1",
@@ -95,9 +95,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source3 = new PublicKeyCredentialSource(
"id3",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p3",
"uh2",
@@ -120,9 +120,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source1 = new PublicKeyCredentialSource(
"id1",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p1",
"uh1",
@@ -135,9 +135,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source1 = new PublicKeyCredentialSource(
"id1",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p1",
"uh1",
@@ -152,9 +152,9 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
$source1 = new PublicKeyCredentialSource(
"id1",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p1",
"uh1",
@@ -168,12 +168,12 @@ class PublicKeyCredentialSourceRepositorySQLiteTest extends TestCase {
class PublicKeyCredentialSourceRepositorySQLiteTestDb extends PublicKeyCredentialSourceRepositorySQLite {
- private $pdo;
+ private PDO $pdo;
public function __construct() {
- $this->pdo = new PDO($this->getPdoUrl(), null, null, array(
+ $this->pdo = new PDO($this->getPdoUrl(), null, null, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
- ));
+ ]);
parent::__construct();
}
protected function getPDO(): PDO {
diff --git a/lam/tests/lib/SecurityTest.php b/lam/tests/lib/SecurityTest.php
index ebe19edcc..2dfe2fc2a 100644
--- a/lam/tests/lib/SecurityTest.php
+++ b/lam/tests/lib/SecurityTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2014 - 2016 Roland Gruber
+ Copyright (C) 2014 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,52 +58,52 @@ class SecurityTest extends TestCase {
public function testMinLength() {
$this->cfg->passwordMinLength = 5;
- $this->checkPwd(array('55555', '666666'), array('1', '22', '333', '4444'));
+ $this->checkPwd(['55555', '666666'], ['1', '22', '333', '4444']);
$this->serverProfile->setPwdPolicyMinLength('7');
- $this->checkPwd(array('7777777'), array('1', '22', '333', '4444', '55555', '666666'));
+ $this->checkPwd(['7777777'], ['1', '22', '333', '4444', '55555', '666666']);
$this->serverProfile->setPwdPolicyMinLength('3');
- $this->checkPwd(array('333', '4444', '55555', '666666', '7777777'), array('1', '22'));
+ $this->checkPwd(['333', '4444', '55555', '666666', '7777777'], ['1', '22']);
}
public function testMinUpper() {
$this->cfg->passwordMinUpper = 3;
- $this->checkPwd(array('55A5AA55', '6BB666BB66', 'ABC'), array ('1A', '2C2C', 'AB3', '44BB'));
+ $this->checkPwd(['55A5AA55', '6BB666BB66', 'ABC'], ['1A', '2C2C', 'AB3', '44BB']);
$this->serverProfile->setPwdPolicyMinUppercase('5');
- $this->checkPwd(array('5AA5AAA5', '6BBB66BBB6', 'ABCDE'), array ('1A', '2C2C', 'AB3', '44BB'));
+ $this->checkPwd(['5AA5AAA5', '6BBB66BBB6', 'ABCDE'], ['1A', '2C2C', 'AB3', '44BB']);
$this->serverProfile->setPwdPolicyMinUppercase('2');
- $this->checkPwd(array('5555A5A5', '6BBB666666', 'AB'), array ('1A', '2C22', 'A33', '444B'));
+ $this->checkPwd(['5555A5A5', '6BBB666666', 'AB'], ['1A', '2C22', 'A33', '444B']);
}
public function testMinLower() {
$this->cfg->passwordMinLower = 3;
- $this->checkPwd(array('55a5aa55', '6bb666bb66', 'abc'), array ('1a', '2c2c', 'ab3', '44bbABC'));
+ $this->checkPwd(['55a5aa55', '6bb666bb66', 'abc'], ['1a', '2c2c', 'ab3', '44bbABC']);
$this->serverProfile->setPwdPolicyMinLowercase('5');
- $this->checkPwd(array('5aa5aaa5', '6bbb66bb66', 'abcde'), array ('1abcd', '2c2c', 'ab3', '44bbABC'));
+ $this->checkPwd(['5aa5aaa5', '6bbb66bb66', 'abcde'], ['1abcd', '2c2c', 'ab3', '44bbABC']);
$this->serverProfile->setPwdPolicyMinLowercase('2');
- $this->checkPwd(array('5555aa55', '6bb6666b66', 'ab'), array ('1a', '2c23', 'a13', '441bABC'));
+ $this->checkPwd(['5555aa55', '6bb6666b66', 'ab'], ['1a', '2c23', 'a13', '441bABC']);
}
public function testMinNumeric() {
$this->cfg->passwordMinNumeric = 3;
- $this->checkPwd(array('333', '4444'), array('1', '22', '33A', '44bb'));
+ $this->checkPwd(['333', '4444'], ['1', '22', '33A', '44bb']);
$this->serverProfile->setPwdPolicyMinNumeric('5');
- $this->checkPwd(array('55555'), array('1', '22', '33A', '44bb', '333', '4444'));
+ $this->checkPwd(['55555'], ['1', '22', '33A', '44bb', '333', '4444']);
$this->serverProfile->setPwdPolicyMinNumeric('2');
- $this->checkPwd(array('22', '33A', '44bb', '333', '4444'), array('1', 'X'));
+ $this->checkPwd(['22', '33A', '44bb', '333', '4444'], ['1', 'X']);
}
public function testMinSymbol() {
$this->cfg->passwordMinSymbol = 3;
- $this->checkPwd(array('---', '++++'), array('1.', '2.2.', '3+3+A', '44bb'));
+ $this->checkPwd(['---', '++++'], ['1.', '2.2.', '3+3+A', '44bb']);
$this->serverProfile->setPwdPolicyMinSymbolic('5');
- $this->checkPwd(array('---++', '++--++'), array('1.', '2.2.', '3+3+A--', '44bb'));
+ $this->checkPwd(['---++', '++--++'], ['1.', '2.2.', '3+3+A--', '44bb']);
$this->serverProfile->setPwdPolicyMinSymbolic('2');
- $this->checkPwd(array('-1-', '+x++'), array('1.', '2.', '3+3A', '44bb'));
+ $this->checkPwd(['-1-', '+x++'], ['1.', '2.', '3+3A', '44bb']);
}
public function testMinClasses() {
$this->cfg->passwordMinClasses = 3;
- $this->checkPwd(array('aB.', 'aB.1', 'aa.B99'), array('1', '2.', '3+-', '44bb'));
+ $this->checkPwd(['aB.', 'aB.1', 'aa.B99'], ['1', '2.', '3+-', '44bb']);
}
public function testRulesCount() {
@@ -114,26 +114,26 @@ class SecurityTest extends TestCase {
$this->cfg->passwordMinClasses = 3;
// all rules
$this->cfg->checkedRulesCount = -1;
- $this->checkPwd(array('ABC---abc123', 'ABC123xxx.-.-'), array('1', '2.', '3+-', '44bb', 'ABCabc---22'));
+ $this->checkPwd(['ABC---abc123', 'ABC123xxx.-.-'], ['1', '2.', '3+-', '44bb', 'ABCabc---22']);
// at least 3 rules
$this->cfg->checkedRulesCount = 3;
- $this->checkPwd(array('ABC---abc', 'ABC123.-.-', 'ABCabc-'), array('1', '2.', '3+-', '44bb', 'ABC--22'));
+ $this->checkPwd(['ABC---abc', 'ABC123.-.-', 'ABCabc-'], ['1', '2.', '3+-', '44bb', 'ABC--22']);
}
public function testUser() {
$this->cfg->passwordMustNotContainUser = 'true';
- $this->checkPwd(array('u', 'us', 'use', 'use1r'), array('user', '2user', 'user3'), 'user');
- $this->checkPwd(array('u', 'us', 'use', 'use1r'), array('user', '2user', 'user3', 'test'), array('user', 'test'));
+ $this->checkPwd(['u', 'us', 'use', 'use1r'], ['user', '2user', 'user3'], 'user');
+ $this->checkPwd(['u', 'us', 'use', 'use1r'], ['user', '2user', 'user3', 'test'], ['user', 'test']);
}
public function testUserAttributes() {
$this->cfg->passwordMustNotContain3Chars = 'true';
- $this->checkPwd(array('u', 'us', 'us1e', 'us1er'), array('use', 'user', '2user', 'user3'), 'user');
+ $this->checkPwd(['u', 'us', 'us1e', 'us1er'], ['use', 'user', '2user', 'user3'], 'user');
$this->checkPwd(
- array('uf', 'usfi', 'us1ela3s', 'us1er.la#st'),
- array('use', 'user', '2user', 'user3', 'las', 'last', 'fir', 'first'),
+ ['uf', 'usfi', 'us1ela3s', 'us1er.la#st'],
+ ['use', 'user', '2user', 'user3', 'las', 'last', 'fir', 'first'],
'user',
- array('first', 'last'));
+ ['first', 'last']);
}
/**
@@ -169,7 +169,7 @@ class SecurityTest extends TestCase {
$userName = 'username';
}
if ($otherUserAttrs == null) {
- $otherUserAttrs = array ();
+ $otherUserAttrs = [];
}
foreach ($pwdsToAccept as $pwd) {
$this->assertTrue(checkPasswordStrength($pwd, $userName, $otherUserAttrs));
diff --git a/lam/tests/lib/SelfServiceProfileTest.php b/lam/tests/lib/SelfServiceProfileTest.php
index 5c3a061c8..39f02fd58 100644
--- a/lam/tests/lib/SelfServiceProfileTest.php
+++ b/lam/tests/lib/SelfServiceProfileTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2019 - 2020 Roland Gruber
+ Copyright (C) 2019 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@ class SelfServiceProfileTest extends TestCase {
public function testImportExport() {
$profile = new selfServiceProfile();
- $moduleSettings = array('x1' => 'y1', 'x2' => 'y2');
+ $moduleSettings = ['x1' => 'y1', 'x2' => 'y2'];
$profile->moduleSettings = $moduleSettings;
$profile->baseColor = 'green';
$profile->language = 'de_DE@UTF8';
diff --git a/lam/tests/lib/TypesTest.php b/lam/tests/lib/TypesTest.php
index 5218b07ac..3ffedf0cf 100644
--- a/lam/tests/lib/TypesTest.php
+++ b/lam/tests/lib/TypesTest.php
@@ -6,7 +6,7 @@ use user;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2016 - 2021 Roland Gruber
+ Copyright (C) 2016 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,21 +37,21 @@ class TypesTest extends TestCase {
private $type;
protected function setUp(): void {
- $this->type = $this->getMockBuilder('ConfiguredType')->setMethods(array('getBaseType', 'getModules'))->getMock();
+ $this->type = $this->getMockBuilder('ConfiguredType')->setMethods(['getBaseType', 'getModules'])->getMock();
$scope = new user($this->type);
$this->type->method('getBaseType')->willReturn($scope);
- $this->type->method('getModules')->willReturn(array('posixAccount'));
+ $this->type->method('getModules')->willReturn(['posixAccount']);
}
public function testPreTranslated() {
$attr = new ListAttribute('#uid');
- $this->assertEquals('User name', $attr->getAlias(array('uid' => _('User name'))));
+ $this->assertEquals('User name', $attr->getAlias(['uid' => _('User name')]));
$this->assertEquals('uid', $attr->getAttributeName());
}
public function testCustomAlias() {
$attr = new ListAttribute('uid:My translation');
- $this->assertEquals('My translation', $attr->getAlias(array('uid' => _('User name'))));
+ $this->assertEquals('My translation', $attr->getAlias(['uid' => _('User name')]));
$this->assertEquals('uid', $attr->getAttributeName());
}
diff --git a/lam/tests/lib/WebauthnManagerTest.php b/lam/tests/lib/WebauthnManagerTest.php
index 148fbee53..e5c562374 100644
--- a/lam/tests/lib/WebauthnManagerTest.php
+++ b/lam/tests/lib/WebauthnManagerTest.php
@@ -14,7 +14,7 @@ use \Webauthn\TrustPath\CertificateTrustPath;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2019 - 2021 Roland Gruber
+ Copyright (C) 2019 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ class WebauthnManagerTest extends TestCase {
protected function setup(): void {
$this->database = $this
->getMockBuilder(PublicKeyCredentialSourceRepositorySQLite::class)
- ->onlyMethods(array('getPdoUrl', 'findOneByCredentialId', 'findAllForUserEntity'))
+ ->onlyMethods(['getPdoUrl', 'findOneByCredentialId', 'findAllForUserEntity'])
->getMock();
$file = tmpfile();
$filePath = stream_get_meta_data($file)['uri'];
@@ -68,7 +68,7 @@ class WebauthnManagerTest extends TestCase {
$this->manager = $this
->getMockBuilder(WebauthnManager::class)
- ->onlyMethods(array('getDatabase'))
+ ->onlyMethods(['getDatabase'])
->getMock();
$this->manager->method('getDatabase')->willReturn($this->database);
@@ -85,7 +85,7 @@ class WebauthnManagerTest extends TestCase {
}
public function test_getAuthenticationObject() {
- $this->database->method('findAllForUserEntity')->willReturn(array());
+ $this->database->method('findAllForUserEntity')->willReturn([]);
$authenticationObj = $this->manager->getAuthenticationObject('uid=test,o=test', false);
$this->assertEquals(32, strlen($authenticationObj->getChallenge()));
@@ -99,25 +99,23 @@ class WebauthnManagerTest extends TestCase {
}
public function test_isRegistered_notRegistered() {
- $this->database->method('findAllForUserEntity')->willReturn(array());
+ $this->database->method('findAllForUserEntity')->willReturn([]);
$isRegistered = $this->manager->isRegistered('uid=test,o=test');
$this->assertFalse($isRegistered);
}
public function test_isRegistered_registered() {
- $this->database->method('findAllForUserEntity')->willReturn(array(
- new PublicKeyCredentialSource(
+ $this->database->method('findAllForUserEntity')->willReturn([new PublicKeyCredentialSource(
"id1",
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
- array(),
+ [],
"atype",
- new CertificateTrustPath(array('x5c' => 'test')),
+ new CertificateTrustPath(['x5c' => 'test']),
\Ramsey\Uuid\Uuid::uuid1(),
"p1",
"uh1",
- 1)
- ));
+ 1)]);
$isRegistered = $this->manager->isRegistered('uid=test,o=test');
$this->assertTrue($isRegistered);
diff --git a/lam/tests/lib/WebauthnProviderTest.php b/lam/tests/lib/WebauthnProviderTest.php
index ac071363c..f8bc94d78 100644
--- a/lam/tests/lib/WebauthnProviderTest.php
+++ b/lam/tests/lib/WebauthnProviderTest.php
@@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2020 Roland Gruber
+ Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -63,20 +63,20 @@ class WebauthnProviderTest extends TestCase {
$this->config->twoFactorAuthenticationOptional = true;
$manager = $this
->getMockBuilder(WebauthnManager::class)
- ->setMethods(array('isRegistered'))
+ ->setMethods(['isRegistered'])
->getMock();
$manager->method('isRegistered')->willReturn(false);
$provider = $this
->getMockBuilder(WebauthnProvider::class)
- ->setConstructorArgs(array($this->config))
- ->setMethods(array('getWebauthnManager'))
+ ->setConstructorArgs([$this->config])
+ ->setMethods(['getWebauthnManager'])
->getMock();
$provider->method('getWebauthnManager')->willReturn($manager);
$row = new \htmlResponsiveRow();
$provider->addCustomInput($row, 'userDn');
ob_start();
- $row->generateHTML(null, array(), array(), false, null);
+ $row->generateHTML(null, [], [], false, null);
$html = ob_get_contents();
ob_end_clean();
$this->assertStringContainsString('skip_webauthn', $html);
diff --git a/lam/tests/lib/modules/CustomFieldsTest.php b/lam/tests/lib/modules/CustomFieldsTest.php
index c5a94df3f..2ac068016 100644
--- a/lam/tests/lib/modules/CustomFieldsTest.php
+++ b/lam/tests/lib/modules/CustomFieldsTest.php
@@ -2,7 +2,7 @@
use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2017 - 2021 Roland Gruber
+ Copyright (C) 2017 - 2023 Roland Gruber
*/
if (is_readable('lam/lib/modules/customFields.inc')) {
@@ -24,9 +24,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '((Uid))456';
$originalEnd = '123((uid))';
$originalMultiple = '123((uid))456((uid))789';
- $attributesSet = array('uid' => array('111'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['111']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -50,9 +50,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '%Uid%456';
$originalEnd = '123%uid%';
$originalMultiple = '123%uid%456%uid%789';
- $attributesSet = array('uid' => array('111'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['111']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -76,9 +76,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '@Uid@456';
$originalEnd = '123@uid@';
$originalMultiple = '123@uid@456@uid@789';
- $attributesSet = array('uid' => array('aBc'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['aBc']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -102,9 +102,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '?Uid?456';
$originalEnd = '123?uid?';
$originalMultiple = '123?uid?456?uid?789';
- $attributesSet = array('uid' => array('Abc'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['Abc']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -128,9 +128,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '!Uid!456';
$originalEnd = '123!uid!';
$originalMultiple = '123!uid!456!uid!789';
- $attributesSet = array('uid' => array('abc'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['abc']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -154,9 +154,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '??Uid??456';
$originalEnd = '123??uid??';
$originalMultiple = '123??uid??456??uid??789';
- $attributesSet = array('uid' => array('Abc'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['Abc']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -180,9 +180,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '!!Uid!!456';
$originalEnd = '123!!uid!!';
$originalMultiple = '123!!uid!!456!!uid!!789';
- $attributesSet = array('uid' => array('abc'));
- $attributesNotSet = array('uid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['uid' => ['abc']];
+ $attributesNotSet = ['uid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -206,9 +206,9 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
$originalStart = '§MemberUid|, §456';
$originalEnd = '123§memberUid|, §';
$originalMultiple = '123§memberUid|, §456§memberUid|;§789';
- $attributesSet = array('memberUid' => array('abc', 'cde'));
- $attributesNotSet = array('memberUid' => array(''));
- $attributesNotSet2 = array();
+ $attributesSet = ['memberUid' => ['abc', 'cde']];
+ $attributesNotSet = ['memberUid' => ['']];
+ $attributesNotSet2 = [];
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet, $originalMiddle));
$this->assertEquals('123456', customFieldsConstantEntry::replaceWildcards($attributesNotSet2, $originalMiddle));
@@ -228,11 +228,11 @@ if (is_readable('lam/lib/modules/customFields.inc')) {
}
public function testReplaceWildcardsMixed() {
- $attributes = array(
- 'uid' => array('myuser'),
- 'street' => array('some street'),
- 'memberUid' => array('abc', 'cde')
- );
+ $attributes = [
+ 'uid' => ['myuser'],
+ 'street' => ['some street'],
+ 'memberUid' => ['abc', 'cde']
+ ];
$this->assertEquals('myuser SOME STREET S abc- cde', customFieldsConstantEntry::replaceWildcards($attributes, '%uid% !!street!! !street! §memberuid|- §'));
$this->assertEquals(' MMYUSER', customFieldsConstantEntry::replaceWildcards($attributes, '((uid))!uid!!!uid!!'));
diff --git a/lam/tests/lib/modules/PPolicyUserPasswordNotifyJobTest.php b/lam/tests/lib/modules/PPolicyUserPasswordNotifyJobTest.php
index d1f0c7b0d..60f8b43e0 100644
--- a/lam/tests/lib/modules/PPolicyUserPasswordNotifyJobTest.php
+++ b/lam/tests/lib/modules/PPolicyUserPasswordNotifyJobTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2016 - 2019 Roland Gruber
+ Copyright (C) 2016 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,27 +38,26 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
private $job;
- const JOB_ID = 'jobID';
- const WARNING = '14';
- const DEFAULT_POLICY = 'cn=default,dc=test';
- const NOEXPIRE_POLICY = 'cn=noexpire,dc=test';
- const ONE_YEAR_POLICY = 'cn=policy1,dc=test';
+ public const JOB_ID = 'jobID';
+ public const WARNING = '14';
+ public const DEFAULT_POLICY = 'cn=default,dc=test';
+ public const NOEXPIRE_POLICY = 'cn=noexpire,dc=test';
+ public const ONE_YEAR_POLICY = 'cn=policy1,dc=test';
- private $options = array();
+ private array $options = [];
private $resultLog;
protected function setUp(): void {
$this->job = $this->getMockBuilder('PPolicyPasswordNotifyJob')
- ->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail',
- 'findUsers', 'getConfigPrefix', 'getPolicyOptions'))
+ ->setMethods(['getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail', 'findUsers', 'getConfigPrefix', 'getPolicyOptions'])
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
- $this->job->method('getPolicyOptions')->willReturn(array(
- PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY => array('pwdmaxage' => 365 * 3600 * 24),
- PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY => array('pwdmaxage' => 14 * 3600 * 24),
- PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY => array('pwdmaxage' => 0),
- ));
+ $this->job->method('getPolicyOptions')->willReturn([
+ PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY => ['pwdmaxage' => 365 * 3600 * 24],
+ PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY => ['pwdmaxage' => 14 * 3600 * 24],
+ PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY => ['pwdmaxage' => 0],
+ ]);
$this->options['test_mailNotificationPeriod' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::WARNING;
$this->options['test_mailDefaultPolicy' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY;
$this->resultLog = new \LAM\JOB\JobResultLog();
@@ -66,58 +65,58 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
}
public function testNoAccounts() {
- $this->job->method('findUsers')->willReturn(array());
+ $this->job->method('findUsers')->willReturn([]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testAccountDoesNotExpire() {
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=noexpire,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY),
- 'pwdchangedtime' => array('20000101112233Z')
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY],
+ 'pwdchangedtime' => ['20000101112233Z']
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testAccountLocked() {
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=locked,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdaccountlockedtime' => array('20010101112233Z'),
- 'pwdchangedtime' => array('20000101112233Z')
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdaccountlockedtime' => ['20010101112233Z'],
+ 'pwdchangedtime' => ['20000101112233Z']
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testAccountExpired() {
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=expired,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdchangedtime' => array('20000101112233Z'),
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdchangedtime' => ['20000101112233Z'],
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -127,16 +126,16 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$date = new DateTime('now', new DateTimeZone('UTC'));
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=notReached,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdchangedtime' => [$date->format('YmdHis') . 'Z'],
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -145,17 +144,17 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn($date->format('YmdHis') . 'Z');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=alreadyWarned,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdchangedtime' => [$date->format('YmdHis') . 'Z'],
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -164,17 +163,17 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=alreadyWarned,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdchangedtime' => [$date->format('YmdHis') . 'Z'],
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->once())->method('setDBLastPwdChangeTime');
$this->job->expects($this->once())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -183,24 +182,24 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=alreadyWarned,dc=dn',
- 'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
- 'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
- )));
+ 'pwdpolicysubentry' => [PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY],
+ 'pwdchangedtime' => [$date->format('YmdHis') . 'Z'],
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testGetWarningTimeInSeconds() {
$confDays = 7;
- $policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000);
+ $policy = ['pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000];
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
@@ -208,7 +207,7 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$confDays = -7;
- $policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000);
+ $policy = ['pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000];
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
@@ -216,7 +215,7 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$confDays = 0;
- $policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000);
+ $policy = ['pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000];
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
@@ -224,7 +223,7 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
$confDays = 7;
- $policy = array('pwdmaxage' => 365 * 3600 * 24);
+ $policy = ['pwdmaxage' => 365 * 3600 * 24];
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
diff --git a/lam/tests/lib/modules/QuotaTest.php b/lam/tests/lib/modules/QuotaTest.php
index 1a7c20c62..dd736a5f0 100644
--- a/lam/tests/lib/modules/QuotaTest.php
+++ b/lam/tests/lib/modules/QuotaTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2020 - 2021 Roland Gruber
+ Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ include_once __DIR__ . '/../../../lib/modules/quota.inc';
class QuotaTest extends TestCase {
protected function setUp(): void {
- $_SESSION = array('language' => 'en_GB.utf8');
+ $_SESSION = ['language' => 'en_GB.utf8'];
}
public function testAddBlockUnits() {
diff --git a/lam/tests/lib/modules/ShadowAccountTest.php b/lam/tests/lib/modules/ShadowAccountTest.php
index 9e98e18fd..bf31d2609 100644
--- a/lam/tests/lib/modules/ShadowAccountTest.php
+++ b/lam/tests/lib/modules/ShadowAccountTest.php
@@ -36,79 +36,79 @@ use PHPUnit\Framework\TestCase;
class ShadowAccountTest extends TestCase {
public function test_isAccountExpired_noAttr() {
- $attrs = array('objectClass' => array('shadowAccount'));
+ $attrs = ['objectClass' => ['shadowAccount']];
$this->assertFalse(shadowAccount::isAccountExpired($attrs));
}
public function test_isAccountExpired_notExpired() {
$expire = intval(time() / (24*3600)) + 10000;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowexpire' => array(0 => $expire)
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowexpire' => [0 => $expire]
+ ];
$this->assertFalse(shadowAccount::isAccountExpired($attrs));
}
public function test_isAccountExpired_expired() {
$expire = intval(time() / (24*3600)) - 10000;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowexpire' => array(0 => $expire)
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowexpire' => [0 => $expire]
+ ];
$this->assertTrue(shadowAccount::isAccountExpired($attrs));
}
public function test_isPasswordExpired_noAttr() {
- $attrs = array('objectClass' => array('shadowAccount'));
+ $attrs = ['objectClass' => ['shadowAccount']];
$this->assertFalse(shadowAccount::isPasswordExpired($attrs));
}
public function test_isPasswordExpired_notExpired() {
$change = intval(time() / (24*3600)) - 10;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowlastchange' => array(0 => $change),
- 'shadowmax' => array(0 => '14'),
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowlastchange' => [0 => $change],
+ 'shadowmax' => [0 => '14'],
+ ];
$this->assertFalse(shadowAccount::isPasswordExpired($attrs));
}
public function test_isPasswordExpired_expired() {
$change = intval(time() / (24*3600)) - 10;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowlastchange' => array(0 => $change),
- 'shadowmax' => array(0 => '7'),
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowlastchange' => [0 => $change],
+ 'shadowmax' => [0 => '7'],
+ ];
$this->assertTrue(shadowAccount::isPasswordExpired($attrs));
}
public function test_isPasswordExpired_notExpiredInactiveSet() {
$change = intval(time() / (24*3600)) - 10;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowlastchange' => array(0 => $change),
- 'shadowmax' => array(0 => '7'),
- 'shadowinactive' => array(0 => '14'),
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowlastchange' => [0 => $change],
+ 'shadowmax' => [0 => '7'],
+ 'shadowinactive' => [0 => '14'],
+ ];
$this->assertFalse(shadowAccount::isPasswordExpired($attrs));
}
public function test_isPasswordExpired_expiredInactiveSet() {
$change = intval(time() / (24*3600)) - 10;
- $attrs = array(
- 'objectClass' => array('shadowAccount'),
- 'shadowlastchange' => array(0 => $change),
- 'shadowmax' => array(0 => '7'),
- 'shadowinactive' => array(0 => '2'),
- );
+ $attrs = [
+ 'objectClass' => ['shadowAccount'],
+ 'shadowlastchange' => [0 => $change],
+ 'shadowmax' => [0 => '7'],
+ 'shadowinactive' => [0 => '2'],
+ ];
$this->assertTrue(shadowAccount::isPasswordExpired($attrs));
}
@@ -127,15 +127,15 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
private $job;
- const JOB_ID = 'jobID';
- const WARNING = '14';
+ public const JOB_ID = 'jobID';
+ public const WARNING = '14';
- private $options = array();
+ private array $options = [];
private $resultLog;
public function setUp(): void {
$this->job = $this->getMockBuilder('ShadowAccountPasswordNotifyJob')
- ->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail', 'findUsers', 'getConfigPrefix'))
+ ->setMethods(['getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail', 'findUsers', 'getConfigPrefix'])
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
@@ -144,42 +144,42 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
}
public function testNoAccounts() {
- $this->job->method('findUsers')->willReturn(array());
+ $this->job->method('findUsers')->willReturn([]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testAccountDoesNotExpire() {
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('0'),
- 'shadowlastchange' => array('1')
- )));
+ 'shadowmax' => ['0'],
+ 'shadowlastchange' => ['1']
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
public function testAccountExpired() {
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('10'),
- 'shadowlastchange' => array('1')
- )));
+ 'shadowmax' => ['10'],
+ 'shadowlastchange' => ['1']
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -188,16 +188,16 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('300'),
- 'shadowlastchange' => array($lastChangeNow)
- )));
+ 'shadowmax' => ['300'],
+ 'shadowlastchange' => [$lastChangeNow]
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -206,17 +206,17 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('10'),
- 'shadowlastchange' => array($lastChangeNow)
- )));
+ 'shadowmax' => ['10'],
+ 'shadowlastchange' => [$lastChangeNow]
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -225,17 +225,17 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChange = floor($now->format('U')/3600/24) - 370;
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('365'),
- 'shadowlastchange' => array($lastChange)
- )));
+ 'shadowmax' => ['365'],
+ 'shadowlastchange' => [$lastChange]
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->once())->method('setDBLastPwdChangeTime');
$this->job->expects($this->once())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -244,18 +244,18 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChange = floor($now->format('U')/3600/24) - 370;
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('365'),
+ 'shadowmax' => ['365'],
'shadowwarning' => '10',
- 'shadowlastchange' => array($lastChange)
- )));
+ 'shadowlastchange' => [$lastChange]
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->once())->method('setDBLastPwdChangeTime');
$this->job->expects($this->once())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -264,17 +264,17 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChange = floor($now->format('U')/3600/24) - 380;
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('365'),
+ 'shadowmax' => ['365'],
'shadowwarning' => '10',
- 'shadowlastchange' => array($lastChange)
- )));
+ 'shadowlastchange' => [$lastChange]
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
@@ -283,18 +283,18 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChange = floor($now->format('U')/3600/24) - 373;
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('365'),
+ 'shadowmax' => ['365'],
'shadowwarning' => '20',
- 'shadowlastchange' => array($lastChange)
- )));
+ 'shadowlastchange' => [$lastChange]
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->once())->method('setDBLastPwdChangeTime');
$this->job->expects($this->once())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->options['test_mailNotificationPeriod' . ShadowAccountPasswordNotifyJobTest::JOB_ID][0] = '-10';
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
@@ -304,17 +304,17 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChange = floor($now->format('U')/3600/24) - 377;
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('365'),
+ 'shadowmax' => ['365'],
'shadowwarning' => '20',
- 'shadowlastchange' => array($lastChange)
- )));
+ 'shadowlastchange' => [$lastChange]
+ ]]);
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->options['test_mailNotificationPeriod' . ShadowAccountPasswordNotifyJobTest::JOB_ID][0] = '-10';
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
@@ -324,17 +324,17 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
$now = new DateTime('now', getTimeZone());
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
- $this->job->method('findUsers')->willReturn(array(array(
+ $this->job->method('findUsers')->willReturn([[
'dn' => 'cn=some,dc=dn',
- 'shadowmax' => array('10'),
- 'shadowlastchange' => array($lastChangeNow)
- )));
+ 'shadowmax' => ['10'],
+ 'shadowlastchange' => [$lastChangeNow]
+ ]]);
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
- $pdo = array();
+ $pdo = [];
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true, $this->resultLog);
$this->assertFalse($this->resultLog->hasError());
}
diff --git a/lam/tests/lib/modules/SudoRoleTest.php b/lam/tests/lib/modules/SudoRoleTest.php
index 59ab4cfd8..2d09d0f2c 100644
--- a/lam/tests/lib/modules/SudoRoleTest.php
+++ b/lam/tests/lib/modules/SudoRoleTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2014 - 2019 Roland Gruber
+ Copyright (C) 2014 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -35,19 +35,19 @@ if (is_readable('lam/lib/modules/sudoRole.inc')) {
class SudoRoleTest extends TestCase {
public function testIsValidDate() {
- $valid = array('22.10.2014', '05.01.2013', '1.3.2014', '10.5.2014', '4.12.2015',
- '05.01.2013 22:15', '1.3.2014 5:1', '10.5.2014 13:3', '4.12.2015 5:22');
+ $valid = ['22.10.2014', '05.01.2013', '1.3.2014', '10.5.2014', '4.12.2015',
+ '05.01.2013 22:15', '1.3.2014 5:1', '10.5.2014 13:3', '4.12.2015 5:22'];
foreach ($valid as $testDate) {
$this->assertTrue(sudoRole::isValidDate($testDate));
}
- $invalid = array('10.25.2014', 'abc', '2014-10-12', '10.022014', '10:12', '22.10.2014 12');
+ $invalid = ['10.25.2014', 'abc', '2014-10-12', '10.022014', '10:12', '22.10.2014 12'];
foreach ($invalid as $testDate) {
$this->assertNotTrue(sudoRole::isValidDate($testDate), $testDate);
}
}
public function testEncodeDate() {
- $dates = array(
+ $dates = [
'1.2.2014' => '20140201000000Z',
'10.2.2014' => '20140210000000Z',
'1.11.2014' => '20141101000000Z',
@@ -56,14 +56,14 @@ if (is_readable('lam/lib/modules/sudoRole.inc')) {
'10.2.2014 1:10' => '20140210011000Z',
'1.11.2014 10:2' => '20141101100200Z',
'20.12.2014 10:12' => '20141220101200Z',
- );
+ ];
foreach ($dates as $input => $output) {
$this->assertEquals($output, sudoRole::encodeDate($input), $input . ' ' . $output);
}
}
public function testDecodeDate() {
- $dates = array(
+ $dates = [
'01.02.2014 00:00' => '20140201000000Z',
'10.02.2014 00:00' => '20140210000000Z',
'01.11.2014 00:00' => '20141101000000Z',
@@ -72,7 +72,7 @@ if (is_readable('lam/lib/modules/sudoRole.inc')) {
'10.02.2014 01:10' => '20140210011000Z',
'01.11.2014 10:02' => '20141101100200Z',
'20.12.2014 10:12' => '20141220101200Z',
- );
+ ];
foreach ($dates as $output => $input) {
$this->assertEquals($output, sudoRole::decodeDate($input), $input . ' ' . $output);
}
diff --git a/lam/tests/lib/modules/WindowsUserTest.php b/lam/tests/lib/modules/WindowsUserTest.php
index b653b8653..cb61e2c8f 100644
--- a/lam/tests/lib/modules/WindowsUserTest.php
+++ b/lam/tests/lib/modules/WindowsUserTest.php
@@ -3,7 +3,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2017 - 2020 Roland Gruber
+ Copyright (C) 2017 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,27 +33,27 @@ use PHPUnit\Framework\TestCase;
class WindowsUserTest extends TestCase {
public function test_isAccountExpired_noAttr() {
- $attrs = array('objectClass' => array('user'));
+ $attrs = ['objectClass' => ['user']];
$this->assertFalse(windowsUser::isAccountExpired($attrs));
}
public function test_isAccountExpired_notExpired() {
$expire = $this->getTimeStamp(14);
- $attrs = array(
- 'objectClass' => array('user'),
- 'accounTExpIRes' => array(0 => $expire)
- );
+ $attrs = [
+ 'objectClass' => ['user'],
+ 'accounTExpIRes' => [0 => $expire]
+ ];
$this->assertFalse(windowsUser::isAccountExpired($attrs));
}
public function test_isAccountExpired_expired() {
$expire = $this->getTimeStamp(-14);
- $attrs = array(
- 'objectClass' => array('user'),
- 'accounTExpIRes' => array(0 => $expire)
- );
+ $attrs = [
+ 'objectClass' => ['user'],
+ 'accounTExpIRes' => [0 => $expire]
+ ];
$this->assertTrue(windowsUser::isAccountExpired($attrs));
}
diff --git a/lam/tests/lib/plugins/extendedInvalidCredentials/ExtraInvalidCredentialsTest.php b/lam/tests/lib/plugins/extendedInvalidCredentials/ExtraInvalidCredentialsTest.php
index 7026524a4..937909612 100644
--- a/lam/tests/lib/plugins/extendedInvalidCredentials/ExtraInvalidCredentialsTest.php
+++ b/lam/tests/lib/plugins/extendedInvalidCredentials/ExtraInvalidCredentialsTest.php
@@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2020 Roland Gruber
+ Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,9 +44,9 @@ class ExtraInvalidCredentialsTest extends TestCase {
public function test_getExtraMessage_noMessage() {
$extraInvalidCredentials = $this
->getMockBuilder(ExtraInvalidCredentials::class)
- ->setMethods(array('getLdapData'))
+ ->setMethods(['getLdapData'])
->getMock();
- $extraInvalidCredentials->method('getLdapData')->willReturn(array());
+ $extraInvalidCredentials->method('getLdapData')->willReturn([]);
$this->assertNull($extraInvalidCredentials->getExtraMessage(null, 'testDn'));
}
@@ -57,13 +57,13 @@ class ExtraInvalidCredentialsTest extends TestCase {
public function test_getExtraMessage_ppolicy() {
$extraInvalidCredentials = $this
->getMockBuilder(ExtraInvalidCredentials::class)
- ->setMethods(array('getLdapData'))
+ ->setMethods(['getLdapData'])
->getMock();
$extraInvalidCredentials->method('getLdapData')->willReturn(
- array(
+ [
'dn' => 'uid=test',
- 'pwdaccountlockedtime' => array('1234')
- )
+ 'pwdaccountlockedtime' => ['1234']
+ ]
);
$this->assertNotNull($extraInvalidCredentials->getExtraMessage(null, 'testDn'));
@@ -77,13 +77,13 @@ class ExtraInvalidCredentialsTest extends TestCase {
$time = $time->sub(new DateInterval('P1M'));
$extraInvalidCredentials = $this
->getMockBuilder(ExtraInvalidCredentials::class)
- ->setMethods(array('getLdapData'))
+ ->setMethods(['getLdapData'])
->getMock();
$extraInvalidCredentials->method('getLdapData')->willReturn(
- array(
+ [
'dn' => 'uid=test',
- 'krbpasswordexpiration' => array($time->format('YmdHis') . 'Z')
- )
+ 'krbpasswordexpiration' => [$time->format('YmdHis') . 'Z']
+ ]
);
$this->assertNotNull($extraInvalidCredentials->getExtraMessage(null, 'testDn'));
@@ -97,13 +97,13 @@ class ExtraInvalidCredentialsTest extends TestCase {
$time = $time->sub(new DateInterval('P1M'));
$extraInvalidCredentials = $this
->getMockBuilder(ExtraInvalidCredentials::class)
- ->setMethods(array('getLdapData'))
+ ->setMethods(['getLdapData'])
->getMock();
$extraInvalidCredentials->method('getLdapData')->willReturn(
- array(
+ [
'dn' => 'uid=test',
- 'krbprincipalexpiration' => array($time->format('YmdHis') . 'Z')
- )
+ 'krbprincipalexpiration' => [$time->format('YmdHis') . 'Z']
+ ]
);
$this->assertNotNull($extraInvalidCredentials->getExtraMessage(null, 'testDn'));
diff --git a/lam/tests/tools/multiEdit/MultiEditTest.php b/lam/tests/tools/multiEdit/MultiEditTest.php
index 57ab30554..10b04a590 100644
--- a/lam/tests/tools/multiEdit/MultiEditTest.php
+++ b/lam/tests/tools/multiEdit/MultiEditTest.php
@@ -24,7 +24,7 @@ namespace LAM\TOOLS\MULTI_EDIT;
use PHPUnit\Framework\TestCase;
-include_once (dirname(__FILE__) . '/../../../lib/multiEditTool.inc');
+include_once (__DIR__ . '/../../../lib/multiEditTool.inc');
/**
* Checks code in multiEdit.php.
@@ -35,30 +35,30 @@ include_once (dirname(__FILE__) . '/../../../lib/multiEditTool.inc');
class MultiEditTest extends TestCase {
public function testExtractWildcards() {
- $this->assertEquals(array('abc'), extractWildcards('((abc))'));
- $this->assertEquals(array('abc'), extractWildcards('%abc%'));
- $this->assertEquals(array('abc'), extractWildcards('@abc@'));
- $this->assertEquals(array('abc'), extractWildcards('??abc??'));
- $this->assertEquals(array('abc'), extractWildcards('!!abc!!'));
- $this->assertEquals(array('abc'), extractWildcards('?abc?'));
- $this->assertEquals(array('abc'), extractWildcards('!abc!'));
- $this->assertEquals(array('abc'), extractWildcards('§abc|;§'));
+ $this->assertEquals(['abc'], extractWildcards('((abc))'));
+ $this->assertEquals(['abc'], extractWildcards('%abc%'));
+ $this->assertEquals(['abc'], extractWildcards('@abc@'));
+ $this->assertEquals(['abc'], extractWildcards('??abc??'));
+ $this->assertEquals(['abc'], extractWildcards('!!abc!!'));
+ $this->assertEquals(['abc'], extractWildcards('?abc?'));
+ $this->assertEquals(['abc'], extractWildcards('!abc!'));
+ $this->assertEquals(['abc'], extractWildcards('§abc|;§'));
- $this->assertEquals(array('abc', 'xyz'), extractWildcards('%abc% %xyz%'));
- $this->assertEquals(array('abc', 'xyz'), extractWildcards('%abc% ?xyz?'));
+ $this->assertEquals(['abc', 'xyz'], extractWildcards('%abc% %xyz%'));
+ $this->assertEquals(['abc', 'xyz'], extractWildcards('%abc% ?xyz?'));
- $this->assertEquals(array('abc', 'xyz'), extractWildcards('adc %abc% %xyz% 123'));
- $this->assertEquals(array('abc', 'xyz'), extractWildcards('adc %abc% ?xyz? 123'));
+ $this->assertEquals(['abc', 'xyz'], extractWildcards('adc %abc% %xyz% 123'));
+ $this->assertEquals(['abc', 'xyz'], extractWildcards('adc %abc% ?xyz? 123'));
}
public function testReplaceWildcards() {
- $entry = array(
+ $entry = [
'dn' => 'cn=admin,dc=example,dc=com',
'sn' => array('Steve'),
'givenName' => array('Miller'),
'uid' => array('smiller'),
'description' => array('line1', 'line2')
- );
+ ];
$this->assertEquals('Steve', replaceWildcards('%Sn%', $entry));
$this->assertEquals('S', replaceWildcards('@Sn@', $entry));
$this->assertEquals('s', replaceWildcards('?Sn?', $entry));
diff --git a/phpstan.neon b/phpstan.neon
index 11e386760..6b7ce92ad 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -29,6 +29,7 @@ parameters:
- '#Cannot access offset .* on mixed.#'
- '#Cannot access offset .* on array\|int.#'
- '#Parameter \#1 \$haystack of function str_starts_with expects string, int\|string given.#'
+ - '#Parameter \#3 \$length of function substr expects int\|null, int<0, max>\|false given.#'
- '#Parameter \#1 \$string of function htmlspecialchars expects string, array\|string given.#'
- '#Parameter \#1 \$name of function LAM\\ACCOUNTLIST\\search_username expects string, array\|string given.#'
- '#Parameter \#1 \$array of function array_keys expects array, mixed given.#'