diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-22 13:07:26 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:59 +0100 |
commit | 01b4db62fbc4230cff953a2385d305b149744b86 (patch) | |
tree | 788b5edf5acba069bd6996466ab9b1b30a6804d4 /tests | |
parent | 55ae7fa2a48ce38e2807a40632f282740c0e8117 (diff) | |
download | nextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.tar.gz nextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.zip |
Add dispatcher events to User and Group objects
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-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 |
13 files changed, 216 insertions, 166 deletions
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()); } } |