]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix manager creation and testing
authorJoas Schilling <coding@schilljs.com>
Thu, 22 Oct 2020 08:54:03 +0000 (10:54 +0200)
committerJoas Schilling <coding@schilljs.com>
Thu, 22 Oct 2020 08:54:03 +0000 (10:54 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/ManagerFactory.php
tests/lib/Comments/FakeManager.php
tests/lib/Comments/ManagerTest.php

index 44edf32cf9c39330bd792318924c2f1253abb04f..a5ac2d6554541fb1f0ad8f713261e5d7cd2bcc67 100644 (file)
@@ -56,11 +56,6 @@ class ManagerFactory implements ICommentsManagerFactory {
         * @since 9.0.0
         */
        public function getManager() {
-               return new Manager(
-                       $this->serverContainer->getDatabaseConnection(),
-                       $this->serverContainer->get(LoggerInterface::class),
-                       $this->serverContainer->getConfig(),
-                       $this->serverContainer->get(IInitialStateService::class)
-               );
+               return $this->serverContainer->get(Manager::class);
        }
 }
index 91c8d4b7d587e41772358d696cdad502c407db5b..29fb393436209441c7d570338c925ba62eb7ab78 100644 (file)
@@ -30,7 +30,8 @@ class FakeManager implements ICommentsManager {
                string $objectId,
                int $lastKnownCommentId,
                string $sortDirection = 'asc',
-               int $limit = 30
+               int $limit = 30,
+               bool $includeLastKnown = false
        ): array {
                return [];
        }
@@ -86,4 +87,20 @@ class FakeManager implements ICommentsManager {
 
        public function load(): void {
        }
+
+       public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array {
+               return [];
+       }
+
+       public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int {
+               return 0;
+       }
+
+       public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int {
+               return 0;
+       }
+
+       public function getLastCommentDateByActor(string $objectType, string $objectId, string $verb, string $actorType, array $actors): array {
+               return [];
+       }
 }
index def00fd0dcc011474d4fdfd369e3f830e05b9e2a..a75330625766975c4958fcba2331d14a5c457cf1 100644 (file)
@@ -3,13 +3,18 @@
 namespace Test\Comments;
 
 use OC\Comments\Comment;
+use OC\Comments\Manager;
 use OC\Comments\ManagerFactory;
+use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\Comments\IComment;
 use OCP\Comments\ICommentsEventHandler;
 use OCP\Comments\ICommentsManager;
 use OCP\Comments\NotFoundException;
+use OCP\IConfig;
 use OCP\IDBConnection;
+use OCP\IInitialStateService;
 use OCP\IUser;
+use Psr\Log\LoggerInterface;
 use Test\TestCase;
 
 /**
@@ -63,8 +68,13 @@ class ManagerTest extends TestCase {
        }
 
        protected function getManager() {
-               $factory = new ManagerFactory(\OC::$server);
-               return $factory->getManager();
+               return new Manager(
+                       $this->connection,
+                       $this->createMock(LoggerInterface::class),
+                       $this->createMock(IConfig::class),
+                       $this->createMock(ITimeFactory::class),
+                       $this->createMock(IInitialStateService::class)
+               );
        }