diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-22 15:07:26 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 22:56:59 +0300 |
commit | 01b4db62fbc4230cff953a2385d305b149744b86 (patch) | |
tree | 788b5edf5acba069bd6996466ab9b1b30a6804d4 | |
parent | 55ae7fa2a48ce38e2807a40632f282740c0e8117 (diff) |
Add dispatcher events to User and Group objects
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/files/tests/Service/TagServiceTest.php | 4 | ||||
-rw-r--r-- | apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php | 2 | ||||
-rw-r--r-- | lib/private/Files/View.php | 2 | ||||
-rw-r--r-- | lib/private/Group/Group.php | 66 | ||||
-rw-r--r-- | lib/private/Group/Manager.php | 63 | ||||
-rw-r--r-- | lib/private/Server.php | 7 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 15 | ||||
-rw-r--r-- | lib/private/User/User.php | 47 | ||||
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 45 | ||||
-rw-r--r-- | tests/lib/Files/Cache/CacheTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/FileInfoTest.php | 9 | ||||
-rw-r--r-- | tests/lib/Files/Node/IntegrationTest.php | 2 | ||||
-rw-r--r-- | tests/lib/Files/Node/NodeTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Files/Node/RootTest.php | 9 | ||||
-rw-r--r-- | tests/lib/Group/GroupTest.php | 58 | ||||
-rw-r--r-- | tests/lib/Group/ManagerTest.php | 63 | ||||
-rw-r--r-- | tests/lib/TagsTest.php | 12 | ||||
-rw-r--r-- | tests/lib/User/DatabaseTest.php | 10 | ||||
-rw-r--r-- | tests/lib/User/ManagerTest.php | 54 | ||||
-rw-r--r-- | tests/lib/User/SessionTest.php | 29 | ||||
-rw-r--r-- | tests/lib/User/UserTest.php | 77 |
21 files changed, 332 insertions, 256 deletions
diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index 4e2aeb84246..e4a41bd5d2e 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -27,6 +27,7 @@ namespace OCA\Files\Tests\Service; use OC\Tags; use OCA\Files\Service\TagService; use OCP\Activity\IManager; +use OCP\IUser; use OCP\IUserSession; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -75,8 +76,7 @@ class TagServiceTest extends \Test\TestCase { \OC::$server->getUserManager()->createUser($this->user, 'test'); \OC_User::setUserId($this->user); \OC_Util::setupFS($this->user); - /** @var \OCP\IUser */ - $user = new \OC\User\User($this->user, null); + $user = $this->createMock(IUser::class); /** * @var \OCP\IUserSession */ diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 452d8589a3d..b622fd5221d 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -64,7 +64,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->globalStoragesService = $this->service; - $this->user = new \OC\User\User(self::USER_ID, null); + $this->user = $this->createMock(IUser::class); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 6066aed411f..f12e4609e08 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1299,7 +1299,7 @@ class View { if ($owner instanceof IUser) { return $owner; } else { - return new User($ownerId, null); + return new User($ownerId, null, \OC::$server->getEventDispatcher()); } } diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index df8de7af5d5..3876c575968 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -31,55 +31,50 @@ namespace OC\Group; use OCP\Group\Backend\IHideFromCollaborationBackend; +use OC\Hooks\PublicEmitter; use OCP\GroupInterface; use OCP\IGroup; use OCP\IUser; use OCP\Group\Backend\ICountDisabledInGroup; +use OCP\IUserManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; class Group implements IGroup { /** @var null|string */ protected $displayName; - /** - * @var string $id - */ + /** @var string */ private $gid; - /** - * @var \OC\User\User[] $users - */ + /** @var \OC\User\User[] */ private $users = array(); - /** - * @var bool $usersLoaded - */ + /** @var bool */ private $usersLoaded; - /** - * @var \OC\Group\Backend[]|\OC\Group\Database[] $backend - */ + /** @var Backend[] */ private $backends; - - /** - * @var \OC\Hooks\PublicEmitter $emitter - */ + /** @var EventDispatcherInterface */ + private $dispatcher; + /** @var \OC\User\Manager|IUserManager */ + private $userManager; + /** @var PublicEmitter */ private $emitter; - /** - * @var \OC\User\Manager $userManager - */ - private $userManager; /** * @param string $gid - * @param \OC\Group\Backend[] $backends - * @param \OC\User\Manager $userManager - * @param \OC\Hooks\PublicEmitter $emitter + * @param Backend[] $backends + * @param EventDispatcherInterface $dispatcher + * @param IUserManager $userManager + * @param PublicEmitter $emitter * @param string $displayName */ - public function __construct($gid, $backends, $userManager, $emitter = null, $displayName = null) { + public function __construct(string $gid, array $backends, EventDispatcherInterface $dispatcher, IUserManager $userManager, PublicEmitter $emitter = null, ?string $displayName = null) { $this->gid = $gid; $this->backends = $backends; + $this->dispatcher = $dispatcher; $this->userManager = $userManager; $this->emitter = $emitter; $this->displayName = $displayName; @@ -151,6 +146,10 @@ class Group implements IGroup { return; } + $this->dispatcher->dispatch(IGroup::class . '::preAddUser', new GenericEvent($this, [ + 'user' => $user, + ])); + if ($this->emitter) { $this->emitter->emit('\OC\Group', 'preAddUser', array($this, $user)); } @@ -160,6 +159,11 @@ class Group implements IGroup { if ($this->users) { $this->users[$user->getUID()] = $user; } + + $this->dispatcher->dispatch(IGroup::class . '::postAddUser', new GenericEvent($this, [ + 'user' => $user, + ])); + if ($this->emitter) { $this->emitter->emit('\OC\Group', 'postAddUser', array($this, $user)); } @@ -175,6 +179,9 @@ class Group implements IGroup { */ public function removeUser($user) { $result = false; + $this->dispatcher->dispatch(IGroup::class . '::preRemoveUser', new GenericEvent($this, [ + 'user' => $user, + ])); if ($this->emitter) { $this->emitter->emit('\OC\Group', 'preRemoveUser', array($this, $user)); } @@ -185,6 +192,9 @@ class Group implements IGroup { } } if ($result) { + $this->dispatcher->dispatch(IGroup::class . '::postRemoveUser', new GenericEvent($this, [ + 'user' => $user, + ])); if ($this->emitter) { $this->emitter->emit('\OC\Group', 'postRemoveUser', array($this, $user)); } @@ -292,6 +302,7 @@ class Group implements IGroup { } $result = false; + $this->dispatcher->dispatch(IGroup::class . '::preDelete', new GenericEvent($this)); if ($this->emitter) { $this->emitter->emit('\OC\Group', 'preDelete', array($this)); } @@ -301,8 +312,11 @@ class Group implements IGroup { $backend->deleteGroup($this->gid); } } - if ($result and $this->emitter) { - $this->emitter->emit('\OC\Group', 'postDelete', array($this)); + if ($result) { + $this->dispatcher->dispatch(IGroup::class . '::postDelete', new GenericEvent($this)); + if ($this->emitter) { + $this->emitter->emit('\OC\Group', 'postDelete', array($this)); + } } return $result; } diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index f1bb6357d0a..7567f719b0a 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -44,6 +44,7 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\ILogger; use OCP\IUser; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class Manager @@ -61,39 +62,37 @@ use OCP\IUser; * @package OC\Group */ class Manager extends PublicEmitter implements IGroupManager { - /** - * @var GroupInterface[] $backends - */ - private $backends = array(); + /** @var GroupInterface[] */ + private $backends = []; - /** - * @var \OC\User\Manager $userManager - */ + /** @var \OC\User\Manager */ private $userManager; + /** @var EventDispatcherInterface */ + private $dispatcher; + /** @var ILogger */ + private $logger; - /** - * @var \OC\Group\Group[] - */ - private $cachedGroups = array(); + /** @var \OC\Group\Group[] */ + private $cachedGroups = []; - /** - * @var \OC\Group\Group[] - */ - private $cachedUserGroups = array(); + /** @var \OC\Group\Group[] */ + private $cachedUserGroups = []; /** @var \OC\SubAdmin */ private $subAdmin = null; - /** @var ILogger */ - private $logger; - /** * @param \OC\User\Manager $userManager + * @param EventDispatcherInterface $dispatcher * @param ILogger $logger */ - public function __construct(\OC\User\Manager $userManager, ILogger $logger) { + public function __construct(\OC\User\Manager $userManager, + EventDispatcherInterface $dispatcher, + ILogger $logger) { $this->userManager = $userManager; + $this->dispatcher = $dispatcher; $this->logger = $logger; + $cachedGroups = & $this->cachedGroups; $cachedUserGroups = & $this->cachedUserGroups; $this->listen('\OC\Group', 'postDelete', function ($group) use (&$cachedGroups, &$cachedUserGroups) { @@ -101,19 +100,19 @@ class Manager extends PublicEmitter implements IGroupManager { * @var \OC\Group\Group $group */ unset($cachedGroups[$group->getGID()]); - $cachedUserGroups = array(); + $cachedUserGroups = []; }); $this->listen('\OC\Group', 'postAddUser', function ($group) use (&$cachedUserGroups) { /** * @var \OC\Group\Group $group */ - $cachedUserGroups = array(); + $cachedUserGroups = []; }); $this->listen('\OC\Group', 'postRemoveUser', function ($group) use (&$cachedUserGroups) { /** * @var \OC\Group\Group $group */ - $cachedUserGroups = array(); + $cachedUserGroups = []; }); } @@ -144,7 +143,7 @@ class Manager extends PublicEmitter implements IGroupManager { } public function clearBackends() { - $this->backends = array(); + $this->backends = []; $this->clearCaches(); } @@ -158,8 +157,8 @@ class Manager extends PublicEmitter implements IGroupManager { protected function clearCaches() { - $this->cachedGroups = array(); - $this->cachedUserGroups = array(); + $this->cachedGroups = []; + $this->cachedUserGroups = []; } /** @@ -179,7 +178,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @return \OCP\IGroup */ protected function getGroupObject($gid, $displayName = null) { - $backends = array(); + $backends = []; foreach ($this->backends as $backend) { if ($backend->implementsActions(\OC\Group\Backend::GROUP_DETAILS)) { $groupData = $backend->getGroupDetails($gid); @@ -197,7 +196,7 @@ class Manager extends PublicEmitter implements IGroupManager { if (count($backends) === 0) { return null; } - $this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this, $displayName); + $this->cachedGroups[$gid] = new Group($gid, $backends, $this->dispatcher, $this->userManager, $this, $displayName); return $this->cachedGroups[$gid]; } @@ -239,7 +238,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @return \OC\Group\Group[] */ public function search($search, $limit = null, $offset = null) { - $groups = array(); + $groups = []; foreach ($this->backends as $backend) { $groupIds = $backend->getGroups($search, $limit, $offset); foreach ($groupIds as $groupId) { @@ -276,7 +275,7 @@ class Manager extends PublicEmitter implements IGroupManager { if (isset($this->cachedUserGroups[$uid])) { return $this->cachedUserGroups[$uid]; } - $groups = array(); + $groups = []; foreach ($this->backends as $backend) { $groupIds = $backend->getUserGroups($uid); if (is_array($groupIds)) { @@ -351,11 +350,11 @@ class Manager extends PublicEmitter implements IGroupManager { public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { $group = $this->get($gid); if(is_null($group)) { - return array(); + return []; } $search = trim($search); - $groupUsers = array(); + $groupUsers = []; if(!empty($search)) { // only user backends have the capability to do a complex search for users @@ -384,7 +383,7 @@ class Manager extends PublicEmitter implements IGroupManager { $groupUsers = $group->searchUsers('', $limit, $offset); } - $matchingUsers = array(); + $matchingUsers = []; foreach($groupUsers as $groupUser) { $matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName(); } diff --git a/lib/private/Server.php b/lib/private/Server.php index 8a49a8a8a94..68aba3645cf 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -316,14 +316,13 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); $this->registerService(\OC\User\Manager::class, function (Server $c) { - $config = $c->getConfig(); - return new \OC\User\Manager($config); + return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher()); }); $this->registerAlias('UserManager', \OC\User\Manager::class); $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); $this->registerService(\OCP\IGroupManager::class, function (Server $c) { - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); + $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); }); @@ -1095,6 +1094,8 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); + $this->registerService('SettingsManager', function (Server $c) { $manager = new \OC\Settings\Manager( $c->getLogger(), diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index f1a2029a7d5..62f02915c39 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -39,6 +39,7 @@ use OCP\IUserBackend; use OCP\IUserManager; use OCP\IConfig; use OCP\UserInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class Manager @@ -68,16 +69,14 @@ class Manager extends PublicEmitter implements IUserManager { */ private $cachedUsers = array(); - /** - * @var \OCP\IConfig $config - */ + /** @var IConfig */ private $config; + /** @var EventDispatcherInterface */ + private $dispatcher; - /** - * @param \OCP\IConfig $config - */ - public function __construct(IConfig $config) { + public function __construct(IConfig $config, EventDispatcherInterface $dispatcher) { $this->config = $config; + $this->dispatcher = $dispatcher; $cachedUsers = &$this->cachedUsers; $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { /** @var \OC\User\User $user */ @@ -156,7 +155,7 @@ class Manager extends PublicEmitter implements IUserManager { return $this->cachedUsers[$uid]; } - $user = new User($uid, $backend, $this, $this->config); + $user = new User($uid, $backend, $this->dispatcher, $this, $this->config); if ($cacheUser) { $this->cachedUsers[$uid] = $user; } diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 06dd47b0887..17fa022b1b7 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -42,30 +42,34 @@ use OCP\IUser; use OCP\IConfig; use OCP\UserInterface; use \OCP\IUserBackend; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; class User implements IUser { - /** @var string $uid */ + /** @var string */ private $uid; - /** @var string $displayName */ + /** @var string */ private $displayName; - /** @var UserInterface $backend */ + /** @var UserInterface|null */ private $backend; + /** @var EventDispatcherInterface */ + private $dispatcher; - /** @var bool $enabled */ + /** @var bool */ private $enabled; - /** @var Emitter|Manager $emitter */ + /** @var Emitter|Manager */ private $emitter; - /** @var string $home */ + /** @var string */ private $home; - /** @var int $lastLogin */ + /** @var int */ private $lastLogin; - /** @var \OCP\IConfig $config */ + /** @var \OCP\IConfig */ private $config; /** @var IAvatarManager */ @@ -74,16 +78,10 @@ class User implements IUser { /** @var IURLGenerator */ private $urlGenerator; - /** - * @param string $uid - * @param UserInterface $backend - * @param \OC\Hooks\Emitter $emitter - * @param IConfig|null $config - * @param IURLGenerator $urlGenerator - */ - public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $urlGenerator = null) { + public function __construct(string $uid, ?UserInterface $backend, EventDispatcherInterface $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) { $this->uid = $uid; $this->backend = $backend; + $this->dispatcher = $dispatcher; $this->emitter = $emitter; if(is_null($config)) { $config = \OC::$server->getConfig(); @@ -115,7 +113,7 @@ class User implements IUser { public function getDisplayName() { if (!isset($this->displayName)) { $displayName = ''; - if ($this->backend and $this->backend->implementsActions(Backend::GET_DISPLAYNAME)) { + if ($this->backend && $this->backend->implementsActions(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)) { @@ -199,6 +197,7 @@ class User implements IUser { * @return bool */ public function delete() { + $this->dispatcher->dispatch(IUser::class . '::preDelete', new GenericEvent($this)); if ($this->emitter) { $this->emitter->emit('\OC\User', 'preDelete', array($this)); } @@ -243,6 +242,7 @@ class User implements IUser { $accountManager = \OC::$server->query(AccountManager::class); $accountManager->deleteUser($this); + $this->dispatcher->dispatch(IUser::class . '::postDelete', new GenericEvent($this)); if ($this->emitter) { $this->emitter->emit('\OC\User', 'postDelete', array($this)); } @@ -258,11 +258,19 @@ class User implements IUser { * @return bool */ public function setPassword($password, $recoveryPassword = null) { + $this->dispatcher->dispatch(IUser::class . '::preSetPassword', new GenericEvent($this, [ + 'password' => $password, + 'recoveryPassword' => $recoveryPassword, + ])); if ($this->emitter) { $this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword)); } if ($this->backend->implementsActions(Backend::SET_PASSWORD)) { $result = $this->backend->setPassword($this->uid, $password); + $this->dispatcher->dispatch(IUser::class . '::postSetPassword', new GenericEvent($this, [ + 'password' => $password, + 'recoveryPassword' => $recoveryPassword, + ])); if ($this->emitter) { $this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword)); } @@ -455,6 +463,11 @@ class User implements IUser { } public function triggerChange($feature, $value = null, $oldValue = null) { + $this->dispatcher->dispatch(IUser::class . '::changeUser', new GenericEvent($this, [ + 'feature' => $feature, + 'value' => $value, + 'oldValue' => $oldValue, + ])); if ($this->emitter) { $this->emitter->emit('\OC\User', 'changeUser', array($this, $feature, $value, $oldValue)); } diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 67188fae633..cb94ccf44d0 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -17,7 +17,9 @@ use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\ICache; use OCP\ICacheFactory; +use OCP\IGroup; use OCP\IGroupManager; +use OCP\IUser; use OCP\IUserSession; use OCP\IAppConfig; use OCP\IConfig; @@ -144,10 +146,14 @@ class AppManagerTest extends TestCase { } public function testEnableAppForGroups() { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; $this->expectClearCache(); /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ @@ -187,10 +193,14 @@ class AppManagerTest extends TestCase { * @param array $appInfo */ public function testEnableAppForGroupsAllowedTypes(array $appInfo) { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; $this->expectClearCache(); /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ @@ -237,10 +247,14 @@ class AppManagerTest extends TestCase { * @expectedExceptionMessage test can't be enabled for groups. */ public function testEnableAppForGroupsForbiddenTypes($type) { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) @@ -284,10 +298,11 @@ class AppManagerTest extends TestCase { } private function newUser($uid) { - $config = $this->createMock(IConfig::class); - $urlgenerator = $this->createMock(IURLGenerator::class); + $user = $this->createMock(IUser::class); + $user->method('getUID') + ->willReturn($uid); - return new User($uid, null, null, $config, $urlgenerator); + return $user; } public function testIsEnabledForUserEnabled() { diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index d984964ca9f..f94b4f57078 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -332,7 +332,7 @@ class CacheTest extends \Test\TestCase { $userId = $this->getUniqueId('user'); \OC::$server->getUserManager()->createUser($userId, $userId); $this->loginAsUser($userId); - $user = new \OC\User\User($userId, null); + $user = new \OC\User\User($userId, null, \OC::$server->getEventDispatcher()); $file1 = 'folder'; $file2 = 'folder/foobar'; @@ -402,7 +402,7 @@ class CacheTest extends \Test\TestCase { $userId = static::getUniqueID('user'); \OC::$server->getUserManager()->createUser($userId, $userId); static::loginAsUser($userId); - $user = new \OC\User\User($userId, null); + $user = new \OC\User\User($userId, null, \OC::$server->getEventDispatcher()); $file1 = 'folder'; $file2 = 'folder/foobar'; diff --git a/tests/lib/Files/FileInfoTest.php b/tests/lib/Files/FileInfoTest.php index ee7a10ccec4..b1ab880ad70 100644 --- a/tests/lib/Files/FileInfoTest.php +++ b/tests/lib/Files/FileInfoTest.php @@ -14,6 +14,7 @@ use OC\Files\Storage\Home; use OC\Files\Storage\Temporary; use OC\User\User; use OCP\IConfig; +use OCP\IUser; use Test\TestCase; use Test\Traits\UserTrait; @@ -29,9 +30,15 @@ class FileInfoTest extends TestCase { } public function testIsMountedHomeStorage() { + $user = $this->createMock(IUser::class); + $user->method('getUID') + ->willReturn('foo'); + $user->method('getHome') + ->willReturn('foo'); + $fileInfo = new FileInfo( '', - new Home(['user' => new User('foo', $this->userBackend, null, $this->config)]), + new Home(['user' => $user]), '', [], null); $this->assertFalse($fileInfo->isMounted()); } diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index b5cd832d1dd..6d9b0ce20b9 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -45,7 +45,7 @@ class IntegrationTest extends \Test\TestCase { \OC_Hook::clear('OC_Filesystem'); - $user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy); + $user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy, \OC::$server->getEventDispatcher()); $this->loginAsUser($user->getUID()); $this->view = new View(); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index 9200ae69f75..dee5a0211c5 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -18,6 +18,7 @@ use OCP\Files\Storage; use OCP\IConfig; use OCP\ILogger; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserManager; use OCP\Files\NotFoundException; @@ -45,14 +46,7 @@ abstract class NodeTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $urlGenerator = $this->getMockBuilder(IURLGenerator - ::class) - ->disableOriginalConstructor() - ->getMock(); - $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlGenerator); + $this->user = $this->createMock(IUser::class); $this->manager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index fd050c8d90c..8a6e5411f26 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -39,14 +39,7 @@ class RootTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $urlgenerator = $this->getMockBuilder(IURLGenerator::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlgenerator); + $this->user = $this->createMock(IUser::class); $this->manager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php index a0b77bbe4d7..5ab7a645081 100644 --- a/tests/lib/Group/GroupTest.php +++ b/tests/lib/Group/GroupTest.php @@ -12,8 +12,19 @@ namespace Test\Group; use OC\User\User; use OCP\IConfig; use OCP\IURLGenerator; +use OCP\IUser; +use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class GroupTest extends \Test\TestCase { + + /** @var EventDispatcherInterface|MockObject */ + protected $dispatcher; + + public function setUp() { + parent::setUp(); + $this->dispatcher = $this->createMock(EventDispatcherInterface::class); + } /** * @param string $uid @@ -21,14 +32,13 @@ class GroupTest extends \Test\TestCase { * @return User */ private function newUser($uid, \OC\User\Backend $backend) { - $config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $urlgenerator = $this->getMockBuilder(IURLGenerator::class) - ->disableOriginalConstructor() - ->getMock(); + $user = $this->createMock(IUser::class); + $user->method('getUID') + ->willReturn($uid); + $user->method('getBackend') + ->willReturn($backend); - return new User($uid, $backend, null, $config, $urlgenerator); + return $user; } /** @@ -59,7 +69,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') @@ -83,7 +93,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') @@ -114,7 +124,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') @@ -135,7 +145,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('inGroup') @@ -158,7 +168,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') @@ -183,7 +193,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') @@ -207,7 +217,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') @@ -232,7 +242,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') @@ -259,7 +269,7 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('inGroup') @@ -293,7 +303,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') @@ -315,7 +325,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') @@ -338,7 +348,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') @@ -360,7 +370,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') @@ -385,7 +395,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1), $userManager); + $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('countUsersInGroup') @@ -409,7 +419,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('countUsersInGroup') @@ -437,7 +447,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1), $userManager); + $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager); $backend1->expects($this->never()) ->method('countUsersInGroup'); @@ -455,7 +465,7 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $userManager); + $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('deleteGroup') diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index 23a35024e0a..32e30217759 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -27,18 +27,23 @@ use OC\User\Manager; use OCP\ILogger; use OCP\IUser; use OCP\GroupInterface; +use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class ManagerTest extends TestCase { - /** @var Manager|\PHPUnit_Framework_MockObject_MockObject $userManager */ + /** @var Manager|MockObject */ protected $userManager; - /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject $userManager */ + /** @var EventDispatcherInterface|MockObject */ + protected $dispatcher; + /** @var ILogger|MockObject */ protected $logger; protected function setUp() { parent::setUp(); $this->userManager = $this->createMock(Manager::class); + $this->dispatcher = $this->createMock(EventDispatcherInterface::class); $this->logger = $this->createMock(ILogger::class); } @@ -101,7 +106,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -110,7 +115,7 @@ class ManagerTest extends TestCase { } public function testGetNoBackend() { - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $this->assertNull($manager->get('group1')); } @@ -125,7 +130,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(false)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $this->assertNull($manager->get('group1')); @@ -135,7 +140,7 @@ class ManagerTest extends TestCase { $backend = new \Test\Util\Group\Dummy(); $backend->createGroup('group1'); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -162,7 +167,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -187,7 +192,7 @@ class ManagerTest extends TestCase { $backendGroupCreated = true; })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -204,7 +209,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('createGroup'); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -225,7 +230,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -259,7 +264,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -296,7 +301,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -323,7 +328,7 @@ class ManagerTest extends TestCase { /** @var \OC\User\Manager $userManager */ $userManager = $this->createMock(Manager::class); - $manager = new \OC\Group\Manager($userManager, $this->logger); + $manager = new \OC\Group\Manager($userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -344,7 +349,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $groups = $manager->getUserGroups($this->getTestUser('user1')); @@ -391,7 +396,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(false)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit_Framework_MockObject_MockObject $user */ @@ -417,7 +422,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $this->assertTrue($manager->isInGroup('user1', 'group1')); @@ -436,7 +441,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $this->assertTrue($manager->isAdmin('user1')); @@ -455,7 +460,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $this->assertFalse($manager->isAdmin('user1')); @@ -486,7 +491,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -545,7 +550,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3'); @@ -605,7 +610,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1); @@ -669,7 +674,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1, 1); @@ -709,7 +714,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', ''); @@ -748,7 +753,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1); @@ -787,7 +792,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1, 1); @@ -815,7 +820,7 @@ class ManagerTest extends TestCase { ->with('group1') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); // prime cache @@ -858,7 +863,7 @@ class ManagerTest extends TestCase { ->method('removeFromGroup') ->will($this->returnValue(true)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); // prime cache @@ -888,7 +893,7 @@ class ManagerTest extends TestCase { ->with('user1') ->will($this->returnValue(null)); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); $groups = $manager->getUserIdGroups('user1'); @@ -914,7 +919,7 @@ class ManagerTest extends TestCase { ['group2', ['gid' => 'group2']], ])); - $manager = new \OC\Group\Manager($this->userManager, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); // group with display name diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php index ce26f6b4807..268521bed51 100644 --- a/tests/lib/TagsTest.php +++ b/tests/lib/TagsTest.php @@ -21,6 +21,7 @@ */ namespace Test; +use OCP\IUser; use OCP\IUserSession; /** @@ -49,7 +50,9 @@ class TagsTest extends \Test\TestCase { $userId = $this->getUniqueID('user_'); \OC::$server->getUserManager()->createUser($userId, 'pass'); \OC_User::setUserId($userId); - $this->user = new \OC\User\User($userId, null); + $this->user = $this->createMock(IUser::class); + $this->user->method('getUID') + ->willReturn($userId); $this->userSession = $this->createMock(IUserSession::class); $this->userSession ->expects($this->any()) @@ -292,14 +295,19 @@ class TagsTest extends \Test\TestCase { $tagger = $this->tagMgr->load('test'); $tagger->tagAs(1, $testTag); + $otherUserId = $this->getUniqueID('user2_'); + $otherUser = $this->createMock(IUser::class); + $otherUser->method('getUID') + ->willReturn($otherUserId); + \OC::$server->getUserManager()->createUser($otherUserId, 'pass'); \OC_User::setUserId($otherUserId); $otherUserSession = $this->createMock(IUserSession::class); $otherUserSession ->expects($this->any()) ->method('getUser') - ->will($this->returnValue(new \OC\User\User($otherUserId, null))); + ->willReturn($otherUser); $otherTagMgr = new \OC\TagManager($this->tagMapper, $otherUserSession); $otherTagger = $otherTagMgr->load('test'); diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php index a6fb8047a98..666833ec44c 100644 --- a/tests/lib/User/DatabaseTest.php +++ b/tests/lib/User/DatabaseTest.php @@ -22,7 +22,7 @@ namespace Test\User; use OC\HintException; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use OC\User\User; @@ -34,7 +34,7 @@ use OC\User\User; class DatabaseTest extends Backend { /** @var array */ private $users; - /** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject */ + /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ private $eventDispatcher; public function getUser() { @@ -46,7 +46,7 @@ class DatabaseTest extends Backend { protected function setUp() { parent::setUp(); - $this->eventDispatcher = $this->createMock(EventDispatcher::class); + $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); $this->backend=new \OC\User\Database($this->eventDispatcher); } @@ -124,8 +124,8 @@ class DatabaseTest extends Backend { $user2 = $this->getUser(); $this->backend->createUser($user2, 'pass1'); - $user1Obj = new User($user1, $this->backend); - $user2Obj = new User($user2, $this->backend); + $user1Obj = new User($user1, $this->backend, $this->eventDispatcher); + $user2Obj = new User($user2, $this->backend, $this->eventDispatcher); $emailAddr1 = "$user1@nextcloud.com"; $emailAddr2 = "$user2@nextcloud.com"; diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index 284f7b173bc..b99d499b2a8 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -13,6 +13,7 @@ use OC\User\Database; use OC\User\Manager; use OCP\IConfig; use OCP\IUser; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -26,16 +27,19 @@ class ManagerTest extends TestCase { /** @var IConfig */ private $config; + /** @var EventDispatcherInterface */ + private $dispatcher; public function setUp() { parent::setUp(); $this->config = $this->createMock(IConfig::class); + $this->dispatcher = $this->createMock(EventDispatcherInterface::class); } public function testGetBackends() { $userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($userDummyBackend); $this->assertEquals([$userDummyBackend], $manager->getBackends()); $dummyDatabaseBackend = $this->createMock(Database::class); @@ -54,7 +58,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(true)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertTrue($manager->userExists('foo')); @@ -70,14 +74,14 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(false)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertFalse($manager->userExists('foo')); } public function testUserExistsNoBackends() { - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $this->assertFalse($manager->userExists('foo')); } @@ -101,7 +105,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(true)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend1); $manager->registerBackend($backend2); @@ -125,7 +129,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->never()) ->method('userExists'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend1); $manager->registerBackend($backend2); @@ -152,7 +156,7 @@ class ManagerTest extends TestCase { } })); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $user = $manager->checkPassword('foo', 'bar'); @@ -171,7 +175,7 @@ class ManagerTest extends TestCase { ->method('implementsActions') ->will($this->returnValue(false)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertFalse($manager->checkPassword('foo', 'bar')); @@ -189,7 +193,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('loginName2UserName'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertEquals('foo', $manager->get('foo')->getUID()); @@ -205,7 +209,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(false)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertEquals(null, $manager->get('foo')); @@ -223,7 +227,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('loginName2UserName'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID()); @@ -241,7 +245,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('loginName2UserName'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $result = $manager->search('fo'); @@ -275,7 +279,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->never()) ->method('loginName2UserName'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend1); $manager->registerBackend($backend2); @@ -329,7 +333,7 @@ class ManagerTest extends TestCase { ->willReturn(true); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->expectException(\InvalidArgumentException::class, $exception); @@ -356,7 +360,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('loginName2UserName'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $user = $manager->createUser('foo', 'bar'); @@ -383,7 +387,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(true)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $manager->createUser('foo', 'bar'); @@ -404,14 +408,14 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('userExists'); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $this->assertFalse($manager->createUser('foo', 'bar')); } public function testCreateUserNoBackends() { - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $this->assertFalse($manager->createUser('foo', 'bar')); } @@ -431,7 +435,7 @@ class ManagerTest extends TestCase { ->with('MyUid', 'MyPassword') ->willReturn(false); - $manager = new Manager($config); + $manager = new Manager($config, $this->dispatcher); $manager->createUserFromBackend('MyUid', 'MyPassword', $backend); } @@ -471,7 +475,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('foo')) ->will($this->returnValue(true)); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend1); $manager->registerBackend($backend2); @@ -479,7 +483,7 @@ class ManagerTest extends TestCase { } public function testCountUsersNoBackend() { - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $result = $manager->countUsers(); $this->assertTrue(is_array($result)); @@ -504,7 +508,7 @@ class ManagerTest extends TestCase { ->method('getBackendName') ->will($this->returnValue('Mock_Test_Util_User_Dummy')); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend); $result = $manager->countUsers(); @@ -545,7 +549,7 @@ class ManagerTest extends TestCase { ->method('getBackendName') ->will($this->returnValue('Mock_Test_Util_User_Dummy')); - $manager = new \OC\User\Manager($this->config); + $manager = new \OC\User\Manager($this->config, $this->dispatcher); $manager->registerBackend($backend1); $manager->registerBackend($backend2); @@ -660,7 +664,7 @@ class ManagerTest extends TestCase { ->with('foo', 'login', 'lastLogin') ->will($this->returnValue(0)); - $manager = new \OC\User\Manager($config); + $manager = new \OC\User\Manager($config, $this->dispatcher); $backend = new \Test\Util\User\Dummy(); $manager->registerBackend($backend); @@ -694,7 +698,7 @@ class ManagerTest extends TestCase { ->with($this->equalTo('uid2')) ->will($this->returnValue(true)); - $manager = new \OC\User\Manager($config); + $manager = new \OC\User\Manager($config, $this->dispatcher); $manager->registerBackend($backend); $users = $manager->getByEmail('test@example.com'); diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 114b2eb5597..f6d86de7291 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -28,6 +28,7 @@ use OCP\IUser; use OCP\Lockdown\ILockdownManager; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * @group DB @@ -167,7 +168,7 @@ class SessionTest extends \Test\TestCase { 'getUser' ]) ->getMock(); - $user = new User('sepp', null); + $user = new User('sepp', null, $this->createMock(EventDispatcherInterface::class)); $userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue($isLoggedIn ? $user : null)); @@ -184,7 +185,7 @@ class SessionTest extends \Test\TestCase { $backend = $this->createMock(\Test\Util\User\Dummy::class); - $user = $this->getMockBuilder(User::class)->setConstructorArgs(['foo', $backend])->getMock(); + $user = $this->createMock(IUser::class); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('foo')); @@ -220,12 +221,12 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $backend = $this->createMock(\Test\Util\User\Dummy::class); - $user = $this->getMockBuilder(User::class)->setConstructorArgs(['foo', $backend])->getMock(); + $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') ->will($this->returnValue(true)); @@ -271,12 +272,12 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $backend = $this->createMock(\Test\Util\User\Dummy::class); - $user = $this->getMockBuilder(User::class)->setConstructorArgs(['foo', $backend])->getMock(); + $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') ->will($this->returnValue(false)); @@ -299,12 +300,12 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $backend = $this->createMock(\Test\Util\User\Dummy::class); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger); - $user = $this->getMockBuilder(User::class)->setConstructorArgs(['foo', $backend])->getMock(); + $user = $this->createMock(IUser::class); $session->expects($this->never()) ->method('set'); @@ -535,7 +536,7 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() @@ -621,7 +622,7 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() @@ -681,7 +682,7 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() @@ -729,7 +730,7 @@ class SessionTest extends \Test\TestCase { $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) ->setMethods($mockedManagerMethods) - ->setConstructorArgs([$this->config]) + ->setConstructorArgs([$this->config, $this->createMock(EventDispatcherInterface::class)]) ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() @@ -765,8 +766,8 @@ class SessionTest extends \Test\TestCase { public function testActiveUserAfterSetSession() { $users = array( - 'foo' => new User('foo', null), - 'bar' => new User('bar', null) + 'foo' => new User('foo', null, $this->createMock(EventDispatcherInterface::class)), + 'bar' => new User('bar', null, $this->createMock(EventDispatcherInterface::class)) ); $manager = $this->getMockBuilder('\OC\User\Manager') diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 2a99e725ec7..16fde814b85 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -17,6 +17,8 @@ use OCP\IUser; use OCP\Notification\IManager as INotificationManager; use OCP\Notification\INotification; use OCP\UserInterface; +use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -27,6 +29,15 @@ use Test\TestCase; * @package Test\User */ class UserTest extends TestCase { + + /** @var EventDispatcherInterface|MockObject */ + protected $dispatcher; + + public function setUp() { + parent::setUp(); + $this->dispatcher = $this->createMock(EventDispatcherInterface::class); + } + public function testDisplayName() { /** * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend @@ -42,7 +53,7 @@ class UserTest extends TestCase { ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) ->will($this->returnValue(true)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('Foo', $user->getDisplayName()); } @@ -64,7 +75,7 @@ class UserTest extends TestCase { ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) ->will($this->returnValue(true)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('foo', $user->getDisplayName()); } @@ -81,7 +92,7 @@ class UserTest extends TestCase { ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) ->will($this->returnValue(false)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('foo', $user->getDisplayName()); } @@ -104,7 +115,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->setPassword('bar','')); } @@ -120,7 +131,7 @@ class UserTest extends TestCase { ->method('implementsActions') ->will($this->returnValue(false)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->setPassword('bar','')); } @@ -144,7 +155,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangeAvatar()); } @@ -168,7 +179,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangeAvatar()); } @@ -184,7 +195,7 @@ class UserTest extends TestCase { ->method('implementsActions') ->willReturn(false); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangeAvatar()); } @@ -197,7 +208,7 @@ class UserTest extends TestCase { ->method('deleteUser') ->with($this->equalTo('foo')); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->delete()); } @@ -229,7 +240,7 @@ class UserTest extends TestCase { ->method('deleteUser') ->with($this->equalTo('foo')); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->delete()); } @@ -253,14 +264,14 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('/home/foo', $user->getHome()); } public function testGetBackendClassName() { - $user = new User('foo', new \Test\Util\User\Dummy()); + $user = new User('foo', new \Test\Util\User\Dummy(), $this->dispatcher); $this->assertEquals('Dummy', $user->getBackendClassName()); - $user = new User('foo', new \OC\User\Database()); + $user = new User('foo', new \OC\User\Database(), $this->dispatcher); $this->assertEquals('Database', $user->getBackendClassName()); } @@ -287,7 +298,7 @@ class UserTest extends TestCase { ->with($this->equalTo('datadirectory')) ->will($this->returnValue('arbitrary/path')); - $user = new User('foo', $backend, null, $allConfig); + $user = new User('foo', $backend, $this->dispatcher, null, $allConfig); $this->assertEquals('arbitrary/path/foo', $user->getHome()); } @@ -307,7 +318,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangePassword()); } @@ -321,7 +332,7 @@ class UserTest extends TestCase { ->method('implementsActions') ->will($this->returnValue(false)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangePassword()); } @@ -341,7 +352,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangeDisplayName()); } @@ -355,7 +366,7 @@ class UserTest extends TestCase { ->method('implementsActions') ->will($this->returnValue(false)); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangeDisplayName()); } @@ -380,7 +391,7 @@ class UserTest extends TestCase { ->with('foo','Foo') ->willReturn(true); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->setDisplayName('Foo')); $this->assertEquals('Foo',$user->getDisplayName()); } @@ -404,7 +415,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->setDisplayName(' ')); $this->assertEquals('foo',$user->getDisplayName()); } @@ -422,7 +433,7 @@ class UserTest extends TestCase { $backend->expects($this->never()) ->method('setDisplayName'); - $user = new User('foo', $backend); + $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->setDisplayName('Foo')); $this->assertEquals('foo',$user->getDisplayName()); } @@ -462,7 +473,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend, $emitter); + $user = new User('foo', $backend, $this->dispatcher, $emitter); $user->setPassword('bar',''); $this->assertEquals(2, $hooksCalled); @@ -492,7 +503,7 @@ class UserTest extends TestCase { ->method('deleteUser') ->willReturn($result); $emitter = new PublicEmitter(); - $user = new User('foo', $backend, $emitter); + $user = new User('foo', $backend, $this->dispatcher, $emitter); /** * @param User $user @@ -573,7 +584,7 @@ class UserTest extends TestCase { ->method('getAbsoluteURL') ->withAnyParameters() ->willReturn('http://localhost:8888/owncloud'); - $user = new User('foo', $backend, null, null, $urlGenerator); + $user = new User('foo', $backend, $this->dispatcher, null, null, $urlGenerator); $this->assertEquals('foo@localhost:8888/owncloud', $user->getCloudId()); } @@ -609,7 +620,7 @@ class UserTest extends TestCase { 'email' ); - $user = new User('foo', $backend, $emitter, $config); + $user = new User('foo', $backend, $this->dispatcher, $emitter, $config); $user->setEMailAddress(''); } @@ -646,7 +657,7 @@ class UserTest extends TestCase { 'foo@bar.com' ); - $user = new User('foo', $backend, $emitter, $config); + $user = new User('foo', $backend, $this->dispatcher, $emitter, $config); $user->setEMailAddress('foo@bar.com'); } @@ -674,7 +685,7 @@ class UserTest extends TestCase { 'foo@bar.com' ); - $user = new User('foo', $backend, $emitter, $config); + $user = new User('foo', $backend, $this->dispatcher, $emitter, $config); $user->setEMailAddress('foo@bar.com'); } @@ -711,7 +722,7 @@ class UserTest extends TestCase { '23 TB' ); - $user = new User('foo', $backend, $emitter, $config); + $user = new User('foo', $backend, $this->dispatcher, $emitter, $config); $user->setQuota('23 TB'); } @@ -739,7 +750,7 @@ class UserTest extends TestCase { '23 TB' ); - $user = new User('foo', $backend, $emitter, $config); + $user = new User('foo', $backend, $this->dispatcher, $emitter, $config); $user->setQuota('23 TB'); } @@ -759,7 +770,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend, null, $config); + $user = new User('foo', $backend, $this->dispatcher, null, $config); $this->assertSame(42, $user->getLastLogin()); } @@ -779,7 +790,7 @@ class UserTest extends TestCase { 'true' ); - $user = new User('foo', $backend, null, $config); + $user = new User('foo', $backend, $this->dispatcher, null, $config); $user->setEnabled(true); } @@ -803,6 +814,7 @@ class UserTest extends TestCase { ->setConstructorArgs([ 'foo', $backend, + $this->dispatcher, null, $config, ]) @@ -836,6 +848,7 @@ class UserTest extends TestCase { ->setConstructorArgs([ 'foo', $backend, + $this->dispatcher, null, $config, ]) @@ -867,7 +880,7 @@ class UserTest extends TestCase { } })); - $user = new User('foo', $backend, null, $config); + $user = new User('foo', $backend, $this->dispatcher, null, $config); $this->assertSame('foo@bar.com', $user->getEMailAddress()); } } |