@@ -13,6 +13,7 @@ $config
|
||||
->notPath('build')
|
||||
->notPath('l10n')
|
||||
->notPath('src')
|
||||
->notPath('node_modules')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__);
|
||||
return $config;
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\AppInfo;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use OC\EventDispatcher\SymfonyAdapter;
|
||||
use OC\Share20\ProviderFactory;
|
||||
use OCA\Deck\Activity\CommentEventHandler;
|
||||
use OCA\Deck\Capabilities;
|
||||
use OCA\Deck\Collaboration\Resources\ResourceProvider;
|
||||
@@ -66,7 +65,6 @@ use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Notification\IManager as NotificationManager;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Share\IProviderFactory;
|
||||
use OCP\Util;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Sharing;
|
||||
|
||||
|
||||
use OC\Files\Cache\Cache;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\Board;
|
||||
@@ -60,7 +59,6 @@ interface IShareProviderBackend {
|
||||
}
|
||||
|
||||
class DeckShareProvider implements \OCP\Share\IShareProvider {
|
||||
|
||||
public const DECK_FOLDER = '/Deck';
|
||||
public const DECK_FOLDER_PLACEHOLDER = '/{DECK_PLACEHOLDER}';
|
||||
|
||||
@@ -117,7 +115,7 @@ class DeckShareProvider implements \OCP\Share\IShareProvider {
|
||||
try {
|
||||
$board = $this->boardMapper->find($boardId);
|
||||
$valid &= !$board->getArchived();
|
||||
} catch (DoesNotExistException|MultipleObjectsReturnedException $e) {
|
||||
} catch (DoesNotExistException | MultipleObjectsReturnedException $e) {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Sharing;
|
||||
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OCA\Deck\Service\ConfigService;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
|
||||
@@ -26,7 +26,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Sharing;
|
||||
|
||||
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\NoPermissionException;
|
||||
@@ -37,7 +36,6 @@ use OCP\IURLGenerator;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class ShareAPIHelper {
|
||||
|
||||
private $urlGenerator;
|
||||
private $timeFactory;
|
||||
private $cardMapper;
|
||||
|
||||
@@ -42,7 +42,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
/** @internal Just for testing the service registration */
|
||||
class MyAttachmentService {
|
||||
class MyAttachmentService implements IAttachmentService {
|
||||
public function extendData(Attachment $attachment) {
|
||||
}
|
||||
public function display(Attachment $attachment) {
|
||||
@@ -84,6 +84,10 @@ class AttachmentServiceTest extends TestCase {
|
||||
private $l10n;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
/**
|
||||
* @var IAttachmentService|MockObject
|
||||
*/
|
||||
private $filesAppServiceImpl;
|
||||
|
||||
/**
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
@@ -92,6 +96,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
parent::setUp();
|
||||
|
||||
$this->attachmentServiceImpl = $this->createMock(IAttachmentService::class);
|
||||
$this->filesAppServiceImpl = $this->createMock(IAttachmentService::class);
|
||||
|
||||
$this->appContainer = $this->createMock(IAppContainer::class);
|
||||
|
||||
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
|
||||
@@ -105,6 +111,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->cacheFactory->expects($this->any())->method('createDistributed')->willReturn($this->cache);
|
||||
|
||||
$this->appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($this->attachmentServiceImpl);
|
||||
$this->appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($this->filesAppServiceImpl);
|
||||
|
||||
$this->application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($this->appContainer);
|
||||
@@ -119,8 +127,12 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$fileAppServiceMock = $this->createMock(FilesAppService::class);
|
||||
|
||||
$appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($fileServiceMock);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($fileAppServiceMock);
|
||||
$appContainer->expects($this->at(2))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
@@ -135,8 +147,10 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
$fileAppServiceMock = $this->createMock(FilesAppService::class);
|
||||
$appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($fileServiceMock);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($fileAppServiceMock);
|
||||
$appContainer->expects($this->at(2))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
|
||||
@@ -123,20 +123,9 @@ class BoardServiceTest extends TestCase {
|
||||
$b3 = new Board();
|
||||
$b3->setId(3);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByUser')
|
||||
->method('findAllForUser')
|
||||
->with('admin')
|
||||
->willReturn([$b1, $b2]);
|
||||
$this->stackMapper->expects($this->any())
|
||||
->method('findAll')
|
||||
->willReturn([]);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByGroups')
|
||||
->with('admin', ['a', 'b', 'c'])
|
||||
->willReturn([$b2, $b3]);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByCircles')
|
||||
->with('admin')
|
||||
->willReturn([]);
|
||||
->willReturn([$b1, $b2, $b3]);
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->groupManager->method('getUserGroupIds')
|
||||
->willReturn(['a', 'b', 'c']);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace OCA\Deck\Controller;
|
||||
|
||||
use OCA\Deck\Service\ConfigService;
|
||||
use OCA\Deck\Service\PermissionService;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IInitialStateService;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
@@ -37,6 +38,7 @@ class PageControllerTest extends \Test\TestCase {
|
||||
private $permissionService;
|
||||
private $initialState;
|
||||
private $configService;
|
||||
private $eventDispatcher;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
@@ -44,9 +46,10 @@ class PageControllerTest extends \Test\TestCase {
|
||||
$this->permissionService = $this->createMock(PermissionService::class);
|
||||
$this->configService = $this->createMock(ConfigService::class);
|
||||
$this->initialState = $this->createMock(IInitialStateService::class);
|
||||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
||||
|
||||
$this->controller = new PageController(
|
||||
'deck', $this->request, $this->permissionService, $this->initialState, $this->configService
|
||||
'deck', $this->request, $this->permissionService, $this->initialState, $this->configService, $this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user