aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/UserLDAPPluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/UserLDAPPluginTest.php')
-rw-r--r--apps/user_ldap/tests/UserLDAPPluginTest.php64
1 files changed, 31 insertions, 33 deletions
diff --git a/apps/user_ldap/tests/UserLDAPPluginTest.php b/apps/user_ldap/tests/UserLDAPPluginTest.php
index 5f11f817771..8a065374e61 100644
--- a/apps/user_ldap/tests/UserLDAPPluginTest.php
+++ b/apps/user_ldap/tests/UserLDAPPluginTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -9,27 +11,23 @@ use OC\User\Backend;
use OCA\User_LDAP\UserPluginManager;
class UserLDAPPluginTest extends \Test\TestCase {
-
- /**
- * @return UserPluginManager
- */
- private function getUserPluginManager() {
+ private function getUserPluginManager(): UserPluginManager {
return new UserPluginManager();
}
public function testImplementsActions(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions'])
->getMock();
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::CREATE_USER);
- $plugin2 = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions'])
+ $plugin2 = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions'])
->getMock();
$plugin2->expects($this->any())
@@ -47,8 +45,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testCreateUser(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'createUser'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'createUser'])
->getMock();
$plugin->expects($this->any())
@@ -66,7 +64,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->createUser('user', 'password');
}
-
+
public function testCreateUserNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements createUser in this LDAP Backend.');
@@ -78,8 +76,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testSetPassword(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'setPassword'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'setPassword'])
->getMock();
$plugin->expects($this->any())
@@ -97,7 +95,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->setPassword('user', 'password');
}
-
+
public function testSetPasswordNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements setPassword in this LDAP Backend.');
@@ -109,8 +107,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testGetHome(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'getHome'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'getHome'])
->getMock();
$plugin->expects($this->any())
@@ -127,7 +125,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->getHome('uid');
}
-
+
public function testGetHomeNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements getHome in this LDAP Backend.');
@@ -139,8 +137,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testGetDisplayName(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'getDisplayName'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'getDisplayName'])
->getMock();
$plugin->expects($this->any())
@@ -157,7 +155,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->getDisplayName('uid');
}
-
+
public function testGetDisplayNameNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements getDisplayName in this LDAP Backend.');
@@ -169,8 +167,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testSetDisplayName(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'setDisplayName'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'setDisplayName'])
->getMock();
$plugin->expects($this->any())
@@ -188,7 +186,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->setDisplayName('user', 'password');
}
-
+
public function testSetDisplayNameNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements setDisplayName in this LDAP Backend.');
@@ -200,8 +198,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testCanChangeAvatar(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'canChangeAvatar'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'canChangeAvatar'])
->getMock();
$plugin->expects($this->any())
@@ -218,7 +216,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->canChangeAvatar('uid');
}
-
+
public function testCanChangeAvatarNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements canChangeAvatar in this LDAP Backend.');
@@ -230,8 +228,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testCountUsers(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'countUsers'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'countUsers'])
->getMock();
$plugin->expects($this->any())
@@ -245,7 +243,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->countUsers();
}
-
+
public function testCountUsersNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements countUsers in this LDAP Backend.');
@@ -257,8 +255,8 @@ class UserLDAPPluginTest extends \Test\TestCase {
public function testDeleteUser(): void {
$pluginManager = $this->getUserPluginManager();
- $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy')
- ->setMethods(['respondToActions', 'canDeleteUser','deleteUser'])
+ $plugin = $this->getMockBuilder(LDAPUserPluginDummy::class)
+ ->onlyMethods(['respondToActions', 'canDeleteUser','deleteUser'])
->getMock();
$plugin->expects($this->any())
@@ -281,7 +279,7 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->deleteUser('uid');
}
-
+
public function testDeleteUserNotRegistered(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('No plugin implements deleteUser in this LDAP Backend.');