summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-05-04 09:09:01 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2016-05-10 19:53:36 +0200
commitf6ee738ba82244447d822982aff93494193f93ab (patch)
tree7285ed39a8e67532aaf2b610b7561f6638604d41
parent9e1d9871a8f45faa1d7dbbb42046bd0919a88a5d (diff)
downloadnextcloud-server-f6ee738ba82244447d822982aff93494193f93ab.tar.gz
nextcloud-server-f6ee738ba82244447d822982aff93494193f93ab.zip
Add \OC\User\Backend
Since some apps (ldap et al) still depend on OC_User_Backend this seemed like the cleanest approach.
-rw-r--r--lib/private/User/Backend.php174
-rw-r--r--lib/private/User/Database.php2
-rw-r--r--lib/private/User/Manager.php6
-rw-r--r--lib/private/User/User.php14
-rw-r--r--lib/private/legacy/user/backend.php133
-rw-r--r--tests/lib/user.php2
-rw-r--r--tests/lib/user/backend.php2
-rw-r--r--tests/lib/user/manager.php4
-rw-r--r--tests/lib/user/user.php72
-rw-r--r--tests/lib/util/user/dummy.php4
10 files changed, 228 insertions, 185 deletions
diff --git a/lib/private/User/Backend.php b/lib/private/User/Backend.php
new file mode 100644
index 00000000000..d5f82dc9621
--- /dev/null
+++ b/lib/private/User/Backend.php
@@ -0,0 +1,174 @@
+<?php
+/**
+ * @author Aldo "xoen" Giambelluca <xoen@xoen.org>
+ * @author Bart Visscher <bartv@thisnet.nl>
+ * @author Björn Schießle <schiessle@owncloud.com>
+ * @author Dominik Schmidt <dev@dominik-schmidt.de>
+ * @author Georg Ehrke <georg@owncloud.com>
+ * @author Jakob Sack <mail@jakobsack.de>
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ * @author Lukas Reschke <lukas@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
+ * @author Sam Tuke <mail@samtuke.com>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @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/>
+ *
+ */
+
+namespace OC\User;
+
+/**
+ * Abstract base class for user management. Provides methods for querying backend
+ * capabilities.
+ */
+abstract class Backend implements \OCP\UserInterface {
+ /**
+ * error code for functions not provided by the user backend
+ */
+ const NOT_IMPLEMENTED = -501;
+
+ /**
+ * actions that user backends can define
+ */
+ const CREATE_USER = 1; // 1 << 0
+ const SET_PASSWORD = 16; // 1 << 4
+ const CHECK_PASSWORD = 256; // 1 << 8
+ const GET_HOME = 4096; // 1 << 12
+ const GET_DISPLAYNAME = 65536; // 1 << 16
+ const SET_DISPLAYNAME = 1048576; // 1 << 20
+ const PROVIDE_AVATAR = 16777216; // 1 << 24
+ const COUNT_USERS = 268435456; // 1 << 28
+
+ protected $possibleActions = array(
+ self::CREATE_USER => 'createUser',
+ self::SET_PASSWORD => 'setPassword',
+ self::CHECK_PASSWORD => 'checkPassword',
+ self::GET_HOME => 'getHome',
+ self::GET_DISPLAYNAME => 'getDisplayName',
+ self::SET_DISPLAYNAME => 'setDisplayName',
+ self::PROVIDE_AVATAR => 'canChangeAvatar',
+ self::COUNT_USERS => 'countUsers',
+ );
+
+ /**
+ * Get all supported actions
+ * @return int bitwise-or'ed actions
+ *
+ * Returns the supported actions as int to be
+ * compared with self::CREATE_USER etc.
+ */
+ public function getSupportedActions() {
+ $actions = 0;
+ foreach($this->possibleActions AS $action => $methodName) {
+ if(method_exists($this, $methodName)) {
+ $actions |= $action;
+ }
+ }
+
+ return $actions;
+ }
+
+ /**
+ * Check if backend implements actions
+ * @param int $actions bitwise-or'ed actions
+ * @return boolean
+ *
+ * Returns the supported actions as int to be
+ * compared with self::CREATE_USER etc.
+ */
+ public function implementsActions($actions) {
+ return (bool)($this->getSupportedActions() & $actions);
+ }
+
+ /**
+ * delete a user
+ * @param string $uid The username of the user to delete
+ * @return bool
+ *
+ * Deletes a user
+ */
+ public function deleteUser( $uid ) {
+ return false;
+ }
+
+ /**
+ * Get a list of all users
+ *
+ * @param string $search
+ * @param null|int $limit
+ * @param null|int $offset
+ * @return string[] an array of all uids
+ */
+ public function getUsers($search = '', $limit = null, $offset = null) {
+ return array();
+ }
+
+ /**
+ * check if a user exists
+ * @param string $uid the username
+ * @return boolean
+ */
+ public function userExists($uid) {
+ return false;
+ }
+
+ /**
+ * get the user's home directory
+ * @param string $uid the username
+ * @return boolean
+ */
+ public function getHome($uid) {
+ return false;
+ }
+
+ /**
+ * get display name of the user
+ * @param string $uid user ID of the user
+ * @return string display name
+ */
+ public function getDisplayName($uid) {
+ return $uid;
+ }
+
+ /**
+ * Get a list of all display names and user ids.
+ *
+ * @param string $search
+ * @param string|null $limit
+ * @param string|null $offset
+ * @return array an array of all displayNames (value) and the corresponding uids (key)
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ $users = $this->getUsers($search, $limit, $offset);
+ foreach ( $users as $user) {
+ $displayNames[$user] = $user;
+ }
+ return $displayNames;
+ }
+
+ /**
+ * Check if a user list is available or not
+ * @return boolean if users can be listed or not
+ */
+ public function hasUserListings() {
+ return false;
+ }
+}
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index ac8b2f96e53..7a4b58e6f40 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -55,7 +55,7 @@ use OC\Cache\CappedMemoryCache;
/**
* Class for user management in a SQL Database (e.g. MySQL, SQLite)
*/
-class Database extends \OC_User_Backend implements \OCP\IUserBackend {
+class Database extends \OC\User\Backend implements \OCP\IUserBackend {
/** @var CappedMemoryCache */
private $cache;
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 37a3e5ba134..a9d9425e24d 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -186,7 +186,7 @@ class Manager extends PublicEmitter implements IUserManager {
$password = str_replace("\0", '', $password);
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::CHECK_PASSWORD)) {
+ if ($backend->implementsActions(\OC\User\Backend::CHECK_PASSWORD)) {
$uid = $backend->checkPassword($loginName, $password);
if ($uid !== false) {
return $this->getUserObject($uid, $backend);
@@ -290,7 +290,7 @@ class Manager extends PublicEmitter implements IUserManager {
$this->emit('\OC\User', 'preCreateUser', array($uid, $password));
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::CREATE_USER)) {
+ if ($backend->implementsActions(\OC\User\Backend::CREATE_USER)) {
$backend->createUser($uid, $password);
$user = $this->getUserObject($uid, $backend);
$this->emit('\OC\User', 'postCreateUser', array($user, $password));
@@ -308,7 +308,7 @@ class Manager extends PublicEmitter implements IUserManager {
public function countUsers() {
$userCountStatistics = array();
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) {
+ if ($backend->implementsActions(\OC\User\Backend::COUNT_USERS)) {
$backendUsers = $backend->countUsers();
if($backendUsers !== false) {
if($backend instanceof IUserBackend) {
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index 36680436769..66ecbd18534 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -110,7 +110,7 @@ class User implements IUser {
public function getDisplayName() {
if (!isset($this->displayName)) {
$displayName = '';
- if ($this->backend and $this->backend->implementsActions(\OC_User_Backend::GET_DISPLAYNAME)) {
+ if ($this->backend and $this->backend->implementsActions(\OC\User\Backend::GET_DISPLAYNAME)) {
// get display name and strip whitespace from the beginning and end of it
$backendDisplayName = $this->backend->getDisplayName($this->uid);
if (is_string($backendDisplayName)) {
@@ -135,7 +135,7 @@ class User implements IUser {
*/
public function setDisplayName($displayName) {
$displayName = trim($displayName);
- if ($this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME) && !empty($displayName)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME) && !empty($displayName)) {
$result = $this->backend->setDisplayName($this->uid, $displayName);
if ($result) {
$this->displayName = $displayName;
@@ -230,7 +230,7 @@ class User implements IUser {
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword));
}
- if ($this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD)) {
$result = $this->backend->setPassword($this->uid, $password);
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword));
@@ -248,7 +248,7 @@ class User implements IUser {
*/
public function getHome() {
if (!$this->home) {
- if ($this->backend->implementsActions(\OC_User_Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
$this->home = $home;
} elseif ($this->config) {
$this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid;
@@ -277,7 +277,7 @@ class User implements IUser {
* @return bool
*/
public function canChangeAvatar() {
- if ($this->backend->implementsActions(\OC_User_Backend::PROVIDE_AVATAR)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::PROVIDE_AVATAR)) {
return $this->backend->canChangeAvatar($this->uid);
}
return true;
@@ -289,7 +289,7 @@ class User implements IUser {
* @return bool
*/
public function canChangePassword() {
- return $this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD);
+ return $this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD);
}
/**
@@ -301,7 +301,7 @@ class User implements IUser {
if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
return false;
}
- return $this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME);
+ return $this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME);
}
/**
diff --git a/lib/private/legacy/user/backend.php b/lib/private/legacy/user/backend.php
index 2bb1df4d6b3..42c7b9aa126 100644
--- a/lib/private/legacy/user/backend.php
+++ b/lib/private/legacy/user/backend.php
@@ -62,137 +62,6 @@ define('OC_USER_BACKEND_COUNT_USERS', 1 << 28);
* Abstract base class for user management. Provides methods for querying backend
* capabilities.
*/
-abstract class OC_User_Backend implements \OCP\UserInterface {
- /**
- * error code for functions not provided by the user backend
- */
- const NOT_IMPLEMENTED = -501;
+abstract class OC_User_Backend extends \OC\User\Backend implements \OCP\UserInterface {
- /**
- * actions that user backends can define
- */
- const CREATE_USER = 1; // 1 << 0
- const SET_PASSWORD = 16; // 1 << 4
- const CHECK_PASSWORD = 256; // 1 << 8
- const GET_HOME = 4096; // 1 << 12
- const GET_DISPLAYNAME = 65536; // 1 << 16
- const SET_DISPLAYNAME = 1048576; // 1 << 20
- const PROVIDE_AVATAR = 16777216; // 1 << 24
- const COUNT_USERS = 268435456; // 1 << 28
-
- protected $possibleActions = array(
- self::CREATE_USER => 'createUser',
- self::SET_PASSWORD => 'setPassword',
- self::CHECK_PASSWORD => 'checkPassword',
- self::GET_HOME => 'getHome',
- self::GET_DISPLAYNAME => 'getDisplayName',
- self::SET_DISPLAYNAME => 'setDisplayName',
- self::PROVIDE_AVATAR => 'canChangeAvatar',
- self::COUNT_USERS => 'countUsers',
- );
-
- /**
- * Get all supported actions
- * @return int bitwise-or'ed actions
- *
- * Returns the supported actions as int to be
- * compared with self::CREATE_USER etc.
- */
- public function getSupportedActions() {
- $actions = 0;
- foreach($this->possibleActions AS $action => $methodName) {
- if(method_exists($this, $methodName)) {
- $actions |= $action;
- }
- }
-
- return $actions;
- }
-
- /**
- * Check if backend implements actions
- * @param int $actions bitwise-or'ed actions
- * @return boolean
- *
- * Returns the supported actions as int to be
- * compared with self::CREATE_USER etc.
- */
- public function implementsActions($actions) {
- return (bool)($this->getSupportedActions() & $actions);
- }
-
- /**
- * delete a user
- * @param string $uid The username of the user to delete
- * @return bool
- *
- * Deletes a user
- */
- public function deleteUser( $uid ) {
- return false;
- }
-
- /**
- * Get a list of all users
- *
- * @param string $search
- * @param null|int $limit
- * @param null|int $offset
- * @return string[] an array of all uids
- */
- public function getUsers($search = '', $limit = null, $offset = null) {
- return array();
- }
-
- /**
- * check if a user exists
- * @param string $uid the username
- * @return boolean
- */
- public function userExists($uid) {
- return false;
- }
-
- /**
- * get the user's home directory
- * @param string $uid the username
- * @return boolean
- */
- public function getHome($uid) {
- return false;
- }
-
- /**
- * get display name of the user
- * @param string $uid user ID of the user
- * @return string display name
- */
- public function getDisplayName($uid) {
- return $uid;
- }
-
- /**
- * Get a list of all display names and user ids.
- *
- * @param string $search
- * @param string|null $limit
- * @param string|null $offset
- * @return array an array of all displayNames (value) and the corresponding uids (key)
- */
- public function getDisplayNames($search = '', $limit = null, $offset = null) {
- $displayNames = array();
- $users = $this->getUsers($search, $limit, $offset);
- foreach ( $users as $user) {
- $displayNames[$user] = $user;
- }
- return $displayNames;
- }
-
- /**
- * Check if a user list is available or not
- * @return boolean if users can be listed or not
- */
- public function hasUserListings() {
- return false;
- }
}
diff --git a/tests/lib/user.php b/tests/lib/user.php
index c4c74cbc254..dc5551d1cad 100644
--- a/tests/lib/user.php
+++ b/tests/lib/user.php
@@ -18,7 +18,7 @@ namespace Test;
*/
class User extends TestCase {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
private $backend;
diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php
index c2040f4e3be..d5bbbe9f406 100644
--- a/tests/lib/user/backend.php
+++ b/tests/lib/user/backend.php
@@ -32,7 +32,7 @@
abstract class Test_User_Backend extends \Test\TestCase {
/**
- * @var OC_User_Backend $backend
+ * @var \OC\User\Backend $backend
*/
protected $backend;
diff --git a/tests/lib/user/manager.php b/tests/lib/user/manager.php
index 90e2f67c995..14221e4a665 100644
--- a/tests/lib/user/manager.php
+++ b/tests/lib/user/manager.php
@@ -118,7 +118,7 @@ class Manager extends \Test\TestCase {
public function testCheckPassword() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -145,7 +145,7 @@ class Manager extends \Test\TestCase {
public function testCheckPasswordNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php
index acb557ccd91..0a972f7bdaa 100644
--- a/tests/lib/user/user.php
+++ b/tests/lib/user/user.php
@@ -21,9 +21,9 @@ use OC\Hooks\PublicEmitter;
class User extends \Test\TestCase {
public function testDisplayName() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Backend');
+ $backend = $this->getMock('\OC\User\Backend');
$backend->expects($this->once())
->method('getDisplayName')
->with($this->equalTo('foo'))
@@ -31,7 +31,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->with($this->equalTo(\OC_USER_BACKEND_GET_DISPLAYNAME))
+ ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
->will($this->returnValue(true));
$user = new \OC\User\User('foo', $backend);
@@ -43,9 +43,9 @@ class User extends \Test\TestCase {
*/
public function testDisplayNameEmpty() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Backend');
+ $backend = $this->getMock('\OC\User\Backend');
$backend->expects($this->once())
->method('getDisplayName')
->with($this->equalTo('foo'))
@@ -53,7 +53,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->with($this->equalTo(\OC_USER_BACKEND_GET_DISPLAYNAME))
+ ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
->will($this->returnValue(true));
$user = new \OC\User\User('foo', $backend);
@@ -62,15 +62,15 @@ class User extends \Test\TestCase {
public function testDisplayNameNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Backend');
+ $backend = $this->getMock('\OC\User\Backend');
$backend->expects($this->never())
->method('getDisplayName');
$backend->expects($this->any())
->method('implementsActions')
- ->with($this->equalTo(\OC_USER_BACKEND_GET_DISPLAYNAME))
+ ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
->will($this->returnValue(false));
$user = new \OC\User\User('foo', $backend);
@@ -79,7 +79,7 @@ class User extends \Test\TestCase {
public function testSetPassword() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -89,7 +89,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_PASSWORD) {
+ if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
@@ -102,7 +102,7 @@ class User extends \Test\TestCase {
public function testSetPasswordNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
@@ -118,7 +118,7 @@ class User extends \Test\TestCase {
public function testChangeAvatarSupportedYes() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
$backend = $this->getMock('Avatar_User_Dummy');
@@ -130,7 +130,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_PROVIDE_AVATAR) {
+ if ($actions === \OC\User\Backend::PROVIDE_AVATAR) {
return true;
} else {
return false;
@@ -143,7 +143,7 @@ class User extends \Test\TestCase {
public function testChangeAvatarSupportedNo() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
$backend = $this->getMock('Avatar_User_Dummy');
@@ -155,7 +155,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_PROVIDE_AVATAR) {
+ if ($actions === \OC\User\Backend::PROVIDE_AVATAR) {
return true;
} else {
return false;
@@ -168,7 +168,7 @@ class User extends \Test\TestCase {
public function testChangeAvatarNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
$backend = $this->getMock('Avatar_User_Dummy');
@@ -187,7 +187,7 @@ class User extends \Test\TestCase {
public function testDelete() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -200,7 +200,7 @@ class User extends \Test\TestCase {
public function testGetHome() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -211,7 +211,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_GET_HOME) {
+ if ($actions === \OC\User\Backend::GET_HOME) {
return true;
} else {
return false;
@@ -231,7 +231,7 @@ class User extends \Test\TestCase {
public function testGetHomeNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
@@ -258,14 +258,14 @@ class User extends \Test\TestCase {
public function testCanChangePassword() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_PASSWORD) {
+ if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
@@ -278,7 +278,7 @@ class User extends \Test\TestCase {
public function testCanChangePasswordNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
@@ -292,14 +292,14 @@ class User extends \Test\TestCase {
public function testCanChangeDisplayName() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_DISPLAYNAME) {
+ if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
@@ -312,7 +312,7 @@ class User extends \Test\TestCase {
public function testCanChangeDisplayNameNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
@@ -326,14 +326,14 @@ class User extends \Test\TestCase {
public function testSetDisplayNameSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\OC\User\Database');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_DISPLAYNAME) {
+ if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
@@ -355,14 +355,14 @@ class User extends \Test\TestCase {
*/
public function testSetDisplayNameEmpty() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\OC\User\Database');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_DISPLAYNAME) {
+ if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
@@ -376,7 +376,7 @@ class User extends \Test\TestCase {
public function testSetDisplayNameNotSupported() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\OC\User\Database');
@@ -399,7 +399,7 @@ class User extends \Test\TestCase {
$test = $this;
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -422,7 +422,7 @@ class User extends \Test\TestCase {
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_SET_PASSWORD) {
+ if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
@@ -440,7 +440,7 @@ class User extends \Test\TestCase {
$test = $this;
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
@@ -465,7 +465,7 @@ class User extends \Test\TestCase {
public function testGetCloudId() {
/**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend = $this->getMock('\Test\Util\User\Dummy');
$urlGenerator = $this->getMockBuilder('\OC\URLGenerator')
diff --git a/tests/lib/util/user/dummy.php b/tests/lib/util/user/dummy.php
index 6e23e22ab67..ea47f5d7d15 100644
--- a/tests/lib/util/user/dummy.php
+++ b/tests/lib/util/user/dummy.php
@@ -27,12 +27,12 @@
namespace Test\Util\User;
-use OC_User_Backend;
+use \OC\User\Backend;
/**
* dummy user backend, does not keep state, only for testing use
*/
-class Dummy extends OC_User_Backend implements \OCP\IUserBackend {
+class Dummy extends Backend implements \OCP\IUserBackend {
private $users = array();
private $displayNames = array();