diff options
Diffstat (limited to 'tests/lib/User/ManagerTest.php')
-rw-r--r-- | tests/lib/User/ManagerTest.php | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index f6318ff353b..8cad7f4241a 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -9,6 +9,8 @@ namespace Test\User; use OC\User\Database; +use OCP\IUser; +use Test\TestCase; /** * Class ManagerTest @@ -17,7 +19,7 @@ use OC\User\Database; * * @package Test\User */ -class ManagerTest extends \Test\TestCase { +class ManagerTest extends TestCase { public function testGetBackends() { $userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class); $manager = new \OC\User\Manager(); @@ -448,6 +450,66 @@ class ManagerTest extends \Test\TestCase { $this->assertEquals(7 + 16, $users); } + public function testCountUsersOnlySeen() { + $manager = \OC::$server->getUserManager(); + // count other users in the db before adding our own + $countBefore = $manager->countUsers(true); + + //Add test users + $user1 = $manager->createUser('testseencount1', 'testseencount1'); + $user1->updateLastLoginTimestamp(); + + $user2 = $manager->createUser('testseencount2', 'testseencount2'); + $user2->updateLastLoginTimestamp(); + + $user3 = $manager->createUser('testseencount3', 'testseencount3'); + + $user4 = $manager->createUser('testseencount4', 'testseencount4'); + $user4->updateLastLoginTimestamp(); + + $this->assertEquals($countBefore + 3, $manager->countUsers(true)); + + //cleanup + $user1->delete(); + $user2->delete(); + $user3->delete(); + $user4->delete(); + } + + public function testCallForSeenUsers() { + $manager = \OC::$server->getUserManager(); + // count other users in the db before adding our own + $count = 0; + $function = function (IUser $user) use (&$count) { + $count++; + }; + $manager->callForAllUsers($function, '', true); + $countBefore = $count; + + //Add test users + $user1 = $manager->createUser('testseen1', 'testseen1'); + $user1->updateLastLoginTimestamp(); + + $user2 = $manager->createUser('testseen2', 'testseen2'); + $user2->updateLastLoginTimestamp(); + + $user3 = $manager->createUser('testseen3', 'testseen3'); + + $user4 = $manager->createUser('testseen4', 'testseen4'); + $user4->updateLastLoginTimestamp(); + + $count = 0; + $manager->callForAllUsers($function, '', true); + + $this->assertEquals($countBefore + 3, $count); + + //cleanup + $user1->delete(); + $user2->delete(); + $user3->delete(); + $user4->delete(); + } + public function testDeleteUser() { $config = $this->getMockBuilder('OCP\IConfig') ->disableOriginalConstructor() |