db = Server::get(IDBConnection::class); $this->shareManager = Server::get(IManager::class); $this->userManager = Server::get(IUserManager::class); $this->mailer = $this->createMock(IMailer::class); // Clear occasional leftover shares from other tests $this->db->executeUpdate('DELETE FROM `*PREFIX*share`'); $this->user1 = $this->getUniqueID('user1_'); $this->user2 = $this->getUniqueID('user2_'); $user1 = $this->userManager->createUser($this->user1, 'longrandompassword'); $user2 = $this->userManager->createUser($this->user2, 'longrandompassword'); $user1->setSystemEMailAddress('user1@test.com'); $user2->setSystemEMailAddress('user2@test.com'); \OC::registerShareHooks(Server::get(SystemConfig::class)); $this->job = new SharesReminderJob( Server::get(ITimeFactory::class), $this->db, Server::get(IManager::class), $this->userManager, Server::get(LoggerInterface::class), Server::get(IURLGenerator::class), Server::get(IFactory::class), $this->mailer, Server::get(Defaults::class), Server::get(IMimeTypeLoader::class), ); } protected function tearDown(): void { $this->db->executeUpdate('DELETE FROM `*PREFIX*share`'); $userManager = Server::get(IUserManager::class); $user1 = $userManager->get($this->user1); if ($user1) { $user1->delete(); } $user2 = $userManager->get($this->user2); if ($user2) { $user2->delete(); } $this->logout(); parent::tearDown(); } public function dataSharesReminder() { $someMail = 'test@test.com'; $noExpirationDate = null; $today = new \DateTime(); // For expiration dates, the time is always automatically set to zero by ShareAPIController $today->setTime(0, 0); $nearFuture = new \DateTime(); $nearFuture->setTimestamp($today->getTimestamp() + 86400 * 1); $farFuture = new \DateTime(); $farFuture->setTimestamp($today->getTimestamp() + 86400 * 2); $permissionRead = Constants::PERMISSION_READ; $permissionCreate = $permissionRead | Constants::PERMISSION_CREATE; $permissionUpdate = $permissionRead | Constants::PERMISSION_UPDATE; $permissionDelete = $permissionRead | Constants::PERMISSION_DELETE; $permissionAll = Constants::PERMISSION_ALL; return [ // No reminders for folders without expiration date [$noExpirationDate, '', false, $permissionRead, false], [$noExpirationDate, '', false, $permissionCreate, false], [$noExpirationDate, '', true, $permissionDelete, false], [$noExpirationDate, '', true, $permissionCreate, false], [$noExpirationDate, $someMail, false, $permissionUpdate, false], [$noExpirationDate, $someMail, false, $permissionCreate, false], [$noExpirationDate, $someMail, true, $permissionRead, false], [$noExpirationDate, $someMail, true, $permissionAll, false], // No reminders for folders with expiration date in the far future [$farFuture, '', false, $permissionRead, false], [$farFuture, '', false, $permissionCreate, false], [$farFuture, '', true, $permissionDelete, false], [$farFuture, '', true, $permissionCreate, false], [$farFuture, $someMail, false, $permissionUpdate, false], [$farFuture, $someMail, false, $permissionCreate, false], [$farFuture, $someMail, true, $permissionRead, false], [$farFuture, $someMail, true, $permissionAll, false], /* Should send reminders for folders with expiration date in the near future if the folder is empty and the user has write permission */ [$nearFuture, '', false, $permissionRead, false], [$nearFuture, '', false, $permissionCreate, false], [$nearFuture, '', true, $permissionDelete, false], [$nearFuture, '', true, $permissionCreate, true], [$nearFuture, $someMail, false, $permissionUpdate, false], [$nearFuture, $someMail, false, $permissionCreate, false], [$nearFuture, $someMail, true, $permissionRead, false], [$nearFuture, $someMail, true, $permissionAll, true], ]; } /** * @dataProvider dataSharesReminder * * @param \DateTime|null $expirationDate Share expiration date * @param string $email Share with this email. If empty, the share is of type TYPE_USER and the sharee is user2 * @param bool $isEmpty Is share folder empty? * @param int $permissions * @param bool $shouldBeReminded */ public function testSharesReminder( ?\DateTime $expirationDate, string $email, bool $isEmpty, int $permissions, bool $shouldBeReminded, ): void { $this->loginAsUser($this->user1); $user1Folder = Server::get(IRootFolder::class)->getUserFolder($this->user1); $testFolder = $user1Folder->newFolder('test'); if (!$isEmpty) { $testFolder->newFile('some_file.txt', 'content'); } $share = $this->shareManager->newShare(); $share->setNode($testFolder) ->setShareType(($email ? IShare::TYPE_EMAIL : IShare::TYPE_USER)) ->setPermissions($permissions) ->setSharedBy($this->user1) ->setSharedWith(($email ?: $this->user2)) ->setExpirationDate($expirationDate); $share = $this->shareManager->createShare($share); $this->logout(); $messageMock = $this->createMock(IMessage::class); $this->mailer->method('createMessage')->willReturn($messageMock); $this->mailer ->expects(($shouldBeReminded ? $this->once() : $this->never())) ->method('send') ->with($messageMock); $messageMock ->expects(($shouldBeReminded ? $this->once() : $this->never())) ->method('setTo') ->with([$email ?: $this->userManager->get($this->user2)->getSystemEMailAddress()]); $this->assertSame(false, $share->getReminderSent()); $this->job->run([]); $share = $this->shareManager->getShareById($share->getFullId()); $this->assertEquals($shouldBeReminded, $share->getReminderSent()); } } Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*-build-*
# QtCreator
*.autosave
#QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*