Fix test mocking

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-12-30 12:54:19 +01:00
parent 7291c46d0d
commit 74814ad614
14 changed files with 32 additions and 55 deletions

View File

@@ -34,16 +34,11 @@ use OCA\Deck\Db\ChangeHelper;
use OCA\Deck\InvalidAttachmentType;
use OCA\Deck\NoPermissionException;
use OCA\Deck\NotFoundException;
use OCA\Deck\Sharing\DeckShareProvider;
use OCA\Deck\StatusException;
use OCP\AppFramework\Http\Response;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IPreview;
use OCP\Share\IShare;
class AttachmentService {
private $attachmentMapper;
@@ -63,7 +58,7 @@ class AttachmentService {
/** @var ChangeHelper */
private $changeHelper;
public function __construct(AttachmentMapper $attachmentMapper, CardMapper $cardMapper, ChangeHelper $changeHelper, PermissionService $permissionService, Application $application, ICacheFactory $cacheFactory, $userId, IL10N $l10n, ActivityManager $activityManager, DeckShareProvider $shareProvider) {
public function __construct(AttachmentMapper $attachmentMapper, CardMapper $cardMapper, ChangeHelper $changeHelper, PermissionService $permissionService, Application $application, ICacheFactory $cacheFactory, $userId, IL10N $l10n, ActivityManager $activityManager) {
$this->attachmentMapper = $attachmentMapper;
$this->cardMapper = $cardMapper;
$this->permissionService = $permissionService;
@@ -156,7 +151,7 @@ class AttachmentService {
foreach (array_keys($this->services) as $attachmentType) {
$service = $this->getService($attachmentType);
if ($service instanceof ICustomAttachmentService) {
$count += $service->getAttachmentCount($cardId);
$count += $service->getAttachmentCount($cardId);
}
}
@@ -212,7 +207,6 @@ class AttachmentService {
}
$service->extendData($attachment);
} catch (InvalidAttachmentType $e) {
// just store the data
}
@@ -259,7 +253,6 @@ class AttachmentService {
} catch (\Exception $e) {
throw new NotFoundException();
}
}
/**

View File

@@ -324,7 +324,7 @@ class BoardService {
'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE] ?? false,
'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE] ?? false
]);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $new_board, ActivityManager::SUBJECT_BOARD_CREATE);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $new_board, ActivityManager::SUBJECT_BOARD_CREATE, [], $userId);
$this->changeHelper->boardChanged($new_board->getId());
$this->eventDispatcher->dispatch(

View File

@@ -133,7 +133,7 @@ class CardService {
return $this->cardMapper->searchRaw($boardIds, $term, $limit, $offset);
}
/**
/**
* @param $cardId
* @return \OCA\Deck\Db\RelationalEntity
* @throws \OCA\Deck\NoPermissionException

View File

@@ -40,7 +40,6 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\Share\IManager;
class FileService implements IAttachmentService {
private $l10n;
@@ -58,8 +57,7 @@ class FileService implements IAttachmentService {
ILogger $logger,
IRootFolder $rootFolder,
IConfig $config,
AttachmentMapper $attachmentMapper,
IManager $shareManager
AttachmentMapper $attachmentMapper
) {
$this->l10n = $l10n;
$this->appData = $appData;
@@ -68,7 +66,6 @@ class FileService implements IAttachmentService {
$this->rootFolder = $rootFolder;
$this->config = $config;
$this->attachmentMapper = $attachmentMapper;
$this->shareManager = $shareManager;
}
/**

View File

@@ -24,25 +24,17 @@
namespace OCA\Deck\Service;
use OCA\Deck\Db\Attachment;
use OCA\Deck\Db\AttachmentMapper;
use OCA\Deck\Sharing\DeckShareProvider;
use OCA\Deck\StatusException;
use OCA\Deck\Exceptions\ConflictException;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\StreamResponse;
use OCP\Constants;
use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IPreview;
use OCP\IRequest;
use OCP\Share;
@@ -50,7 +42,6 @@ use OCP\Share\IManager;
use OCP\Share\IShare;
class FilesAppService implements IAttachmentService, ICustomAttachmentService {
private $request;
private $rootFolder;
private $shareProvider;
@@ -100,7 +91,7 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
}, $shares);
}
function getAttachmentCount(int $cardId): int {
public function getAttachmentCount(int $cardId): int {
/** @var IDBConnection $qb */
$db = \OC::$server->getDatabaseConnection();
$qb = $db->getQueryBuilder();
@@ -247,7 +238,6 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
return;
}
}
}
public function allowUndo() {

View File

@@ -26,7 +26,6 @@ declare(strict_types=1);
namespace OCA\Deck\Service;
/**
* Interface to implement in case attachments are handled by a different backend than
* then oc_deck_attachments table, e.g. for file sharing. When this interface is used
@@ -34,9 +33,7 @@ namespace OCA\Deck\Service;
* table and it is up to the implementation to track attachment to card relation.
*/
interface ICustomAttachmentService {
public function listAttachments(int $cardId): array;
public function getAttachmentCount(int $cardId): int;
}