diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2016-10-19 10:03:29 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-28 08:44:05 +0200 |
commit | f8352fcb8dfb5284520396bdc624b6bf62d18219 (patch) | |
tree | 34cc43159586b971e325efd30f6f16b328f607d7 /tests | |
parent | ad597d498d9298643338df2df0170159b736c12c (diff) | |
download | nextcloud-server-f8352fcb8dfb5284520396bdc624b6bf62d18219.tar.gz nextcloud-server-f8352fcb8dfb5284520396bdc624b6bf62d18219.zip |
introduce callForSeenUsers and countSeenUsers (#26361)
* introduce callForSeenUsers and countSeenUsers
* add tests
* oracle should support not null on clob
* since 9.2.0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Repair/RemoveRootSharesTest.php | 3 | ||||
-rw-r--r-- | tests/lib/User/ManagerTest.php | 64 |
2 files changed, 66 insertions, 1 deletions
diff --git a/tests/lib/Repair/RemoveRootSharesTest.php b/tests/lib/Repair/RemoveRootSharesTest.php index bf255fc7e9b..cfb81cb1ecc 100644 --- a/tests/lib/Repair/RemoveRootSharesTest.php +++ b/tests/lib/Repair/RemoveRootSharesTest.php @@ -106,6 +106,7 @@ class RemoveRootSharesTest extends \Test\TestCase { $user = $this->userManager->createUser('test', 'test'); $userFolder = $this->rootFolder->getUserFolder('test'); $fileId = $userFolder->getId(); + $user->updateLastLoginTimestamp(); //Now insert cyclic share $qb = $this->connection->getQueryBuilder(); @@ -134,6 +135,7 @@ class RemoveRootSharesTest extends \Test\TestCase { $user1 = $this->userManager->createUser('test1', 'test1'); $userFolder = $this->rootFolder->getUserFolder('test1'); $fileId = $userFolder->getId(); + $user1->updateLastLoginTimestamp(); //Now insert cyclic share $qb = $this->connection->getQueryBuilder(); @@ -156,6 +158,7 @@ class RemoveRootSharesTest extends \Test\TestCase { $userFolder = $this->rootFolder->getUserFolder('test2'); $folder = $userFolder->newFolder('foo'); $fileId = $folder->getId(); + $user2->updateLastLoginTimestamp(); //Now insert cyclic share $qb = $this->connection->getQueryBuilder(); 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() |