Use IUser::setEMailAddress in ldap as well

This commit is contained in:
Thomas Müller 2016-01-19 15:48:38 +01:00
parent 51b50bd260
commit 77069f5582
11 changed files with 132 additions and 103 deletions

View file

@ -54,7 +54,8 @@ $userManager = new \OCA\user_ldap\lib\user\Manager(
new \OCA\user_ldap\lib\LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection());
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager());
$access = new \OCA\user_ldap\lib\Access($con, $ldapWrapper, $userManager);

View file

@ -37,7 +37,8 @@ if(count($configPrefixes) === 1) {
new OCA\user_ldap\lib\LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc
$dbc,
\OC::$server->getUserManager()
);
$connector = new OCA\user_ldap\lib\Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new OCA\user_ldap\lib\Access($connector, $ldapWrapper, $userManager);

View file

@ -175,7 +175,8 @@ class Jobs extends \OC\BackgroundJob\TimedJob {
new LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc);
$dbc,
\OC::$server->getUserManager());
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager);
$groupMapper = new GroupMapping($dbc);

View file

@ -61,6 +61,7 @@ abstract class Proxy {
static $userMap;
static $groupMap;
static $db;
static $userManager;
if(is_null($fs)) {
$ocConfig = \OC::$server->getConfig();
$fs = new FilesystemHelper();
@ -69,9 +70,10 @@ abstract class Proxy {
$db = \OC::$server->getDatabaseConnection();
$userMap = new UserMapping($db);
$groupMap = new GroupMapping($db);
$userManager = \OC::$server->getUserManager();
}
$userManager =
new user\Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db);
new user\Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $userManager);
$connector = new Connection($this->ldap, $configPrefix);
$access = new Access($connector, $this->ldap, $userManager);
$access->setUserMapper($userMap);

View file

@ -29,6 +29,11 @@ use OCA\user_ldap\lib\user\User;
use OCA\user_ldap\lib\LogWrapper;
use OCA\user_ldap\lib\FilesystemHelper;
use OCA\user_ldap\lib\user\OfflineUser;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
/**
* Manager
@ -40,10 +45,10 @@ class Manager {
/** @var IUserTools */
protected $access;
/** @var \OCP\IConfig */
/** @var IConfig */
protected $ocConfig;
/** @var \OCP\IDBConnection */
/** @var IDBConnection */
protected $db;
/** @var FilesystemHelper */
@ -52,7 +57,7 @@ class Manager {
/** @var LogWrapper */
protected $ocLog;
/** @var \OCP\Image */
/** @var Image */
protected $image;
/** @param \OCP\IAvatarManager */
@ -69,18 +74,19 @@ class Manager {
);
/**
* @param \OCP\IConfig $ocConfig
* @param IConfig $ocConfig
* @param \OCA\user_ldap\lib\FilesystemHelper $ocFilesystem object that
* gives access to necessary functions from the OC filesystem
* @param \OCA\user_ldap\lib\LogWrapper $ocLog
* @param \OCP\IAvatarManager $avatarManager
* @param \OCP\Image $image an empty image instance
* @param \OCP\IDBConnection $db
* @param IAvatarManager $avatarManager
* @param Image $image an empty image instance
* @param IDBConnection $db
* @throws \Exception when the methods mentioned above do not exist
*/
public function __construct(\OCP\IConfig $ocConfig,
FilesystemHelper $ocFilesystem, LogWrapper $ocLog,
\OCP\IAvatarManager $avatarManager, \OCP\Image $image, \OCP\IDBConnection $db) {
public function __construct(IConfig $ocConfig,
FilesystemHelper $ocFilesystem, LogWrapper $ocLog,
IAvatarManager $avatarManager, Image $image,
IDBConnection $db, IUserManager $userManager) {
$this->ocConfig = $ocConfig;
$this->ocFilesystem = $ocFilesystem;
@ -88,6 +94,7 @@ class Manager {
$this->avatarManager = $avatarManager;
$this->image = $image;
$this->db = $db;
$this->userManager = $userManager;
}
/**
@ -110,7 +117,7 @@ class Manager {
$this->checkAccess();
$user = new User($uid, $dn, $this->access, $this->ocConfig,
$this->ocFilesystem, clone $this->image, $this->ocLog,
$this->avatarManager);
$this->avatarManager, $this->userManager);
$this->users['byDN'][$dn] = $user;
$this->users['byUid'][$uid] = $user;
return $user;

View file

@ -27,6 +27,9 @@ use OCA\user_ldap\lib\user\IUserTools;
use OCA\user_ldap\lib\Connection;
use OCA\user_ldap\lib\FilesystemHelper;
use OCA\user_ldap\lib\LogWrapper;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IUserManager;
/**
* User
@ -43,7 +46,7 @@ class User {
*/
protected $connection;
/**
* @var \OCP\IConfig
* @var IConfig
*/
protected $config;
/**
@ -59,10 +62,13 @@ class User {
*/
protected $log;
/**
* @var \OCP\IAvatarManager
* @var IAvatarManager
*/
protected $avatarManager;
/**
* @var IUserManager
*/
protected $userManager;
/**
* @var string
*/
@ -92,15 +98,16 @@ class User {
* @param string $dn the LDAP DN
* @param IUserTools $access an instance that implements IUserTools for
* LDAP interaction
* @param \OCP\IConfig $config
* @param IConfig $config
* @param FilesystemHelper $fs
* @param \OCP\Image $image any empty instance
* @param LogWrapper $log
* @param \OCP\IAvatarManager $avatarManager
* @param IAvatarManager $avatarManager
* @param IUserManager $userManager
*/
public function __construct($username, $dn, IUserTools $access,
\OCP\IConfig $config, FilesystemHelper $fs, \OCP\Image $image,
LogWrapper $log, \OCP\IAvatarManager $avatarManager) {
IConfig $config, FilesystemHelper $fs, \OCP\Image $image,
LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager) {
$this->access = $access;
$this->connection = $access->getConnection();
@ -111,6 +118,7 @@ class User {
$this->image = $image;
$this->log = $log;
$this->avatarManager = $avatarManager;
$this->userManager = $userManager;
}
/**
@ -400,11 +408,8 @@ class User {
}
}
if(!is_null($email)) {
//
// TODO: user IUser::setEMailAddress()
//
$this->config->setUserValue(
$this->uid, 'settings', 'email', $email);
$user = $this->userManager->get($this->uid);
$user->setEMailAddress($email);
}
}

View file

@ -58,7 +58,8 @@ class Test_Access extends \Test\TestCase {
$this->getMock('\OCA\user_ldap\lib\LogWrapper'),
$this->getMock('\OCP\IAvatarManager'),
$this->getMock('\OCP\Image'),
$this->getMock('\OCP\IDBConnection')));
$this->getMock('\OCP\IDBConnection'),
$this->getMock('\OCP\IUserManager')));
return array($lw, $connector, $um);
}

View file

@ -123,7 +123,8 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
new \OCA\user_ldap\lib\LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection()
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager()
);
}

View file

@ -44,6 +44,7 @@ class Test_User_Manager extends \Test\TestCase {
$avaMgr = $this->getMock('\OCP\IAvatarManager');
$image = $this->getMock('\OCP\Image');
$dbc = $this->getMock('\OCP\IDBConnection');
$userMgr = $this->getMock('\OCP\IUserManager');
$connection = new \OCA\user_ldap\lib\Connection(
$lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper'),
@ -55,11 +56,11 @@ class Test_User_Manager extends \Test\TestCase {
->method('getConnection')
->will($this->returnValue($connection));
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc);
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
}
public function testGetByDNExisting() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$inputDN = 'cn=foo,dc=foobar,dc=bar';
@ -78,7 +79,7 @@ class Test_User_Manager extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@ -90,7 +91,7 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetByEDirectoryDN() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$inputDN = 'uid=foo,o=foobar,c=bar';
@ -109,7 +110,7 @@ class Test_User_Manager extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@ -117,7 +118,7 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetByExoticDN() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$inputDN = 'ab=cde,f=ghei,mno=pq';
@ -136,7 +137,7 @@ class Test_User_Manager extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@ -144,7 +145,7 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetByDNNotExisting() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$inputDN = 'cn=gone,dc=foobar,dc=bar';
@ -164,7 +165,7 @@ class Test_User_Manager extends \Test\TestCase {
->with($this->equalTo($inputDN))
->will($this->returnValue(false));
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@ -172,7 +173,7 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetByUidExisting() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$dn = 'cn=foo,dc=foobar,dc=bar';
@ -191,7 +192,7 @@ class Test_User_Manager extends \Test\TestCase {
->with($this->equalTo($uid))
->will($this->returnValue(false));
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($uid);
@ -203,7 +204,7 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetByUidNotExisting() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$dn = 'cn=foo,dc=foobar,dc=bar';
@ -217,7 +218,7 @@ class Test_User_Manager extends \Test\TestCase {
->with($this->equalTo($uid))
->will($this->returnValue(false));
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$user = $manager->get($uid);
@ -225,10 +226,10 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetAttributesAll() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$connection = $access->getConnection();
@ -243,10 +244,10 @@ class Test_User_Manager extends \Test\TestCase {
}
public function testGetAttributesMinimal() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
$manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
$manager->setLdapAccess($access);
$attributes = $manager->getAttributes(true);

View file

@ -25,6 +25,7 @@
namespace OCA\user_ldap\tests;
use OCA\user_ldap\lib\user\User;
use OCP\IUserManager;
/**
* Class Test_User_User
@ -43,11 +44,12 @@ class Test_User_User extends \Test\TestCase {
$avaMgr = $this->getMock('\OCP\IAvatarManager');
$image = $this->getMock('\OCP\Image');
$dbc = $this->getMock('\OCP\IDBConnection');
$userMgr = $this->getMock('\OCP\IUserManager');
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc);
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
}
private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc) {
private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc, $userMgr = null) {
static $conMethods;
static $accMethods;
static $umMethods;
@ -61,8 +63,11 @@ class Test_User_User extends \Test\TestCase {
}
$lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper');
$im = $this->getMock('\OCP\Image');
if (is_null($userMgr)) {
$userMgr = $this->getMock('\OCP\IUserManager');
}
$um = $this->getMock('\OCA\user_ldap\lib\user\Manager',
$umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc));
$umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr));
$connector = $this->getMock('\OCA\user_ldap\lib\Connection',
$conMethods, array($lw, null, null));
$access = $this->getMock('\OCA\user_ldap\lib\Access',
@ -72,25 +77,25 @@ class Test_User_User extends \Test\TestCase {
}
public function testGetDNandUsername() {
list($access, $config, $filesys, $image, $log, $avaMgr) =
list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
$this->getTestInstances();
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$this->assertSame($dn, $user->getDN());
$this->assertSame($uid, $user->getUsername());
}
public function testUpdateEmailProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
$this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc);
$this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr);
$connection->expects($this->once())
->method('__get')
@ -103,24 +108,27 @@ class Test_User_User extends \Test\TestCase {
$this->equalTo('email'))
->will($this->returnValue(array('alice@foo.bar')));
$config->expects($this->once())
->method('setUserValue')
->with($this->equalTo('alice'), $this->equalTo('settings'),
$this->equalTo('email'),
$this->equalTo('alice@foo.bar'))
->will($this->returnValue(true));
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
$uuser = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$uuser->expects($this->once())
->method('setEMailAddress')
->with('alice@foo.bar');
/** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $userMgr */
$userMgr->expects($this->any())
->method('get')
->willReturn($uuser);
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateEmail();
}
public function testUpdateEmailNotProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -144,13 +152,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateEmail();
}
public function testUpdateEmailNotConfigured() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -171,13 +179,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateEmail();
}
public function testUpdateQuotaAllProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -214,13 +222,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota();
}
public function testUpdateQuotaDefaultProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -257,13 +265,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota();
}
public function testUpdateQuotaIndividualProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -300,13 +308,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota();
}
public function testUpdateQuotaNoneProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -338,13 +346,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota();
}
public function testUpdateQuotaNoneConfigured() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -373,13 +381,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota();
}
public function testUpdateQuotaFromValue() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -412,14 +420,14 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateQuota($readQuota);
}
//the testUpdateAvatar series also implicitely tests getAvatarImage
public function testUpdateAvatarJpegPhotoProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -462,13 +470,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateAvatar();
}
public function testUpdateAvatarThumbnailPhotoProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -520,13 +528,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateAvatar();
}
public function testUpdateAvatarNotProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -566,13 +574,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->updateAvatar();
}
public function testUpdateBeforeFirstLogin() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -602,13 +610,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->update();
}
public function testUpdateAfterFirstLogin() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -642,13 +650,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->update();
}
public function testUpdateNoRefresh() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -678,13 +686,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->update();
}
public function testMarkLogin() {
list($access, $config, $filesys, $image, $log, $avaMgr) =
list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
$this->getTestInstances();
$config->expects($this->once())
@ -699,13 +707,13 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->markLogin();
}
public function testGetAvatarImageProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr) =
list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
$this->getTestInstances();
$access->expects($this->once())
@ -718,7 +726,7 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$photo = $user->getAvatarImage();
$this->assertSame('this is a photo', $photo);
@ -728,7 +736,7 @@ class Test_User_User extends \Test\TestCase {
}
public function testProcessAttributes() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -748,7 +756,7 @@ class Test_User_User extends \Test\TestCase {
);
$userMock = $this->getMockBuilder('OCA\user_ldap\lib\user\User')
->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr))
->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr))
->setMethods($requiredMethods)
->getMock();
@ -795,7 +803,7 @@ class Test_User_User extends \Test\TestCase {
* @dataProvider emptyHomeFolderAttributeValueProvider
*/
public function testGetHomePathNotConfigured($attributeValue) {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -816,14 +824,14 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$path = $user->getHomePath();
$this->assertSame($path, false);
}
public function testGetHomePathConfiguredNotAvailableAllowed() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
@ -847,7 +855,7 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$path = $user->getHomePath();
@ -858,11 +866,11 @@ class Test_User_User extends \Test\TestCase {
* @expectedException \Exception
*/
public function testGetHomePathConfiguredNotAvailableNotAllowed() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances();
list($access, $connection) =
$this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc);
$this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr);
$connection->expects($this->any())
->method('__get')
@ -882,7 +890,7 @@ class Test_User_User extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
$uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
$user->getHomePath();
}

View file

@ -84,7 +84,8 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
$this->getMock('\OCA\user_ldap\lib\LogWrapper'),
$this->getMock('\OCP\IAvatarManager'),
$this->getMock('\OCP\Image'),
$this->getMock('\OCP\IDBConnection')
$this->getMock('\OCP\IDBConnection'),
$this->getMock('\OCP\IUserManager')
])
->getMock();