aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/WizardTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/WizardTest.php')
-rw-r--r--apps/user_ldap/tests/WizardTest.php64
1 files changed, 20 insertions, 44 deletions
diff --git a/apps/user_ldap/tests/WizardTest.php b/apps/user_ldap/tests/WizardTest.php
index 9cd6afc8007..3ae9a409e88 100644
--- a/apps/user_ldap/tests/WizardTest.php
+++ b/apps/user_ldap/tests/WizardTest.php
@@ -1,30 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- * @author Viktor Szépe <viktor@szepe.net>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\User_LDAP\Tests;
@@ -56,32 +36,28 @@ class WizardTest extends TestCase {
}
}
- private function getWizardAndMocks() {
+ private function getWizardAndMocks(): array {
static $confMethods;
- static $connMethods;
- static $accMethods;
if (is_null($confMethods)) {
$confMethods = get_class_methods('\OCA\User_LDAP\Configuration');
- $connMethods = get_class_methods('\OCA\User_LDAP\Connection');
- $accMethods = get_class_methods('\OCA\User_LDAP\Access');
}
- /** @var ILDAPWrapper|\PHPUnit\Framework\MockObject\MockObject $lw */
+ /** @var ILDAPWrapper&MockObject $lw */
$lw = $this->createMock(ILDAPWrapper::class);
- /** @var Configuration|\PHPUnit\Framework\MockObject\MockObject $conf */
+ /** @var Configuration&MockObject $conf */
$conf = $this->getMockBuilder(Configuration::class)
- ->setMethods($confMethods)
+ ->onlyMethods($confMethods)
->setConstructorArgs(['', true])
->getMock();
- /** @var Access|\PHPUnit\Framework\MockObject\MockObject $access */
+ /** @var Access&MockObject $access */
$access = $this->createMock(Access::class);
return [new Wizard($conf, $lw, $access), $conf, $lw, $access];
}
- private function prepareLdapWrapperForConnections(MockObject &$ldap) {
+ private function prepareLdapWrapperForConnections(MockObject $ldap) {
$ldap->expects($this->once())
->method('connect')
//dummy value
@@ -96,7 +72,7 @@ class WizardTest extends TestCase {
->willReturn(true);
}
- public function testCumulativeSearchOnAttributeLimited() {
+ public function testCumulativeSearchOnAttributeLimited(): void {
[$wizard, $configuration, $ldap] = $this->getWizardAndMocks();
$configuration->expects($this->any())
@@ -156,7 +132,7 @@ class WizardTest extends TestCase {
unset($uidnumber);
}
- public function testCumulativeSearchOnAttributeUnlimited() {
+ public function testCumulativeSearchOnAttributeUnlimited(): void {
[$wizard, $configuration, $ldap] = $this->getWizardAndMocks();
$configuration->expects($this->any())
@@ -232,7 +208,7 @@ class WizardTest extends TestCase {
unset($uidnumber);
}
- public function testDetectEmailAttributeAlreadySet() {
+ public function testDetectEmailAttributeAlreadySet(): void {
[$wizard, $configuration, $ldap, $access]
= $this->getWizardAndMocks();
@@ -254,7 +230,7 @@ class WizardTest extends TestCase {
$wizard->detectEmailAttribute();
}
- public function testDetectEmailAttributeOverrideSet() {
+ public function testDetectEmailAttributeOverrideSet(): void {
[$wizard, $configuration, $ldap, $access]
= $this->getWizardAndMocks();
@@ -293,7 +269,7 @@ class WizardTest extends TestCase {
$result['changes']['ldap_email_attr']);
}
- public function testDetectEmailAttributeFind() {
+ public function testDetectEmailAttributeFind(): void {
[$wizard, $configuration, $ldap, $access]
= $this->getWizardAndMocks();
@@ -332,7 +308,7 @@ class WizardTest extends TestCase {
$result['changes']['ldap_email_attr']);
}
- public function testDetectEmailAttributeFindNothing() {
+ public function testDetectEmailAttributeFindNothing(): void {
[$wizard, $configuration, $ldap, $access]
= $this->getWizardAndMocks();
@@ -367,10 +343,10 @@ class WizardTest extends TestCase {
});
$result = $wizard->detectEmailAttribute();
- $this->assertSame(false, $result->hasChanges());
+ $this->assertFalse($result->hasChanges());
}
- public function testCumulativeSearchOnAttributeSkipReadDN() {
+ public function testCumulativeSearchOnAttributeSkipReadDN(): void {
// tests that there is no infinite loop, when skipping already processed
// DNs (they can be returned multiple times for multiple filters )
[$wizard, $configuration, $ldap] = $this->getWizardAndMocks();
@@ -444,7 +420,7 @@ class WizardTest extends TestCase {
// The following expectations are the real test
$filters = ['f1', 'f2', '*'];
$resultArray = $wizard->cumulativeSearchOnAttribute($filters, 'cn', 0);
- $this->assertSame(6, count($resultArray));
+ $this->assertCount(6, $resultArray);
unset($mark);
}
}