Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Collaboration/Resources/ResourceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\QueryException;
use OCP\Collaboration\Resources\IManager;
use OCP\Collaboration\Resources\IProvider;
use OCP\Collaboration\Resources\IResource;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;

class ResourceProvider implements IProvider {
public const RESOURCE_TYPE = 'deck';
Expand Down Expand Up @@ -106,7 +106,7 @@ public function invalidateAccessCache($boardId = null) {
try {
/** @var IManager $resourceManager */
$resourceManager = Server::get(IManager::class);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
}
if ($boardId !== null) {
$resource = $resourceManager->getResourceForUser(self::RESOURCE_TYPE, (string)$boardId, null);
Expand Down
4 changes: 2 additions & 2 deletions lib/Collaboration/Resources/ResourceProviderCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\QueryException;
use OCP\Collaboration\Resources\IManager;
use OCP\Collaboration\Resources\IProvider;
use OCP\Collaboration\Resources\IResource;
use OCP\Collaboration\Resources\ResourceException;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;

class ResourceProviderCard implements IProvider {
public const RESOURCE_TYPE = 'deck-card';
Expand Down Expand Up @@ -127,7 +127,7 @@ public function invalidateAccessCache($cardId = null) {
try {
/** @var IManager $resourceManager */
$resourceManager = Server::get(IManager::class);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
}
if ($cardId !== null) {
$resource = $resourceManager->getResourceForUser(self::RESOURCE_TYPE, (string)$cardId, null);
Expand Down
38 changes: 13 additions & 25 deletions tests/unit/Service/AttachmentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
use OCA\Deck\NotFoundException;
use OCA\Deck\Validators\AttachmentServiceValidator;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\IAppContainer;
use OCP\IL10N;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Test\TestCase;

/** @internal Just for testing the service registration */
Expand Down Expand Up @@ -98,16 +98,13 @@ class AttachmentServiceTest extends TestCase {
*/
private $attachmentServiceValidator;

/**
* @throws \OCP\AppFramework\QueryException
*/
public function setUp(): void {
parent::setUp();

$this->attachmentServiceImpl = $this->createMock(IAttachmentService::class);
$this->filesAppServiceImpl = $this->createMock(IAttachmentService::class);

$this->appContainer = $this->createMock(IAppContainer::class);
$this->appContainer = $this->createMock(ContainerInterface::class);

$this->userManager = $this->createMock(IUserManager::class);
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
Expand All @@ -119,14 +116,10 @@ public function setUp(): void {

$this->appContainer->expects($this->exactly(2))
->method('get')
->withConsecutive(
[FileService::class],
[FilesAppService::class]
)
->willReturnOnConsecutiveCalls(
$this->attachmentServiceImpl,
$this->filesAppServiceImpl
);
->willReturnMap([
[FileService::class, $this->attachmentServiceImpl],
[FilesAppService::class, $this->filesAppServiceImpl],
]);

$this->application->expects($this->any())
->method('getContainer')
Expand All @@ -153,7 +146,7 @@ public function setUp(): void {

public function testRegisterAttachmentService() {
$application = $this->createMock(Application::class);
$appContainer = $this->createMock(IAppContainer::class);
$appContainer = $this->createMock(ContainerInterface::class);
$fileServiceMock = $this->createMock(FileService::class);
$fileAppServiceMock = $this->createMock(FilesAppService::class);

Expand Down Expand Up @@ -182,22 +175,17 @@ public function testRegisterAttachmentService() {
public function testRegisterAttachmentServiceNotExisting() {
$this->expectException(InvalidAttachmentType::class);
$application = $this->createMock(Application::class);
$appContainer = $this->createMock(IAppContainer::class);
$appContainer = $this->createMock(ContainerInterface::class);
$fileServiceMock = $this->createMock(FileService::class);
$fileAppServiceMock = $this->createMock(FilesAppService::class);

$appContainer->expects($this->exactly(3))
->method('get')
->withConsecutive(
[FileService::class],
[FilesAppService::class],
[MyAttachmentService::class]
)
->willReturnOnConsecutiveCalls(
$fileServiceMock,
$fileAppServiceMock,
new MyAttachmentService()
);
->willReturnMap([
[FileService::class, $fileServiceMock],
[FilesAppService::class, $fileAppServiceMock],
[MyAttachmentService::class, new MyAttachmentService()],
]);

$application->expects($this->any())
->method('getContainer')
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Service/BatchQueryPerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use OCA\Deck\Notification\NotificationHelper;
use OCA\Deck\Validators\AttachmentServiceValidator;
use OCA\Deck\Validators\CardServiceValidator;
use OCP\AppFramework\IAppContainer;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
Expand All @@ -49,6 +48,7 @@
use OCP\IUser;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Test\TestCase;

Expand Down Expand Up @@ -321,7 +321,7 @@ private function setUpAttachmentService(): void {
// FilesAppService implements ICustomAttachmentService, so mock the full class
$this->filesAppServiceImpl = $this->createMock(FilesAppService::class);

$appContainer = $this->createMock(IAppContainer::class);
$appContainer = $this->createMock(ContainerInterface::class);
$appContainer->method('get')
->willReturnMap([
[FileService::class, $this->fileServiceImpl],
Expand Down
Loading