From 45b3f6e2b32bbfe0a180040eab4b84af00d39453 Mon Sep 17 00:00:00 2001 From: Benjamin Gaussorgues Date: Wed, 5 Jul 2023 11:42:41 +0200 Subject: [PATCH] Migrate federated file sharing to PSR LoggerInterface Signed-off-by: Benjamin Gaussorgues --- .../lib/BackgroundJob/RetryJob.php | 1 - .../Controller/MountPublicLinkController.php | 73 ++-------- .../lib/FederatedShareProvider.php | 93 ++----------- .../lib/Notifications.php | 50 ++----- .../lib/OCM/CloudFederationProviderFiles.php | 131 +++--------------- .../MountPublicLinkControllerTest.php | 33 +++-- .../tests/FederatedShareProviderTest.php | 33 +++-- .../tests/NotificationsTest.php | 30 ++-- lib/private/Share20/ProviderFactory.php | 8 +- 9 files changed, 114 insertions(+), 338 deletions(-) diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php index f785f4fc528..98fe20bf46e 100644 --- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php +++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php @@ -30,7 +30,6 @@ use OCA\FederatedFileSharing\Notifications; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\Job; -use OCP\ILogger; /** * Class RetryJob diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 404077e46af..7042715b70c 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -41,12 +41,12 @@ use OCP\Federation\ICloudIdManager; use OCP\HintException; use OCP\Http\Client\IClientService; use OCP\IL10N; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IUserSession; use OCP\Share\IManager; use OCP\Share\IShare; +use Psr\Log\LoggerInterface; /** * Class MountPublicLinkController @@ -56,66 +56,23 @@ use OCP\Share\IShare; * @package OCA\FederatedFileSharing\Controller */ class MountPublicLinkController extends Controller { - - /** @var FederatedShareProvider */ - private $federatedShareProvider; - - /** @var AddressHandler */ - private $addressHandler; - - /** @var IManager */ - private $shareManager; - - /** @var ISession */ - private $session; - - /** @var IL10N */ - private $l; - - /** @var IUserSession */ - private $userSession; - - /** @var IClientService */ - private $clientService; - - /** @var ICloudIdManager */ - private $cloudIdManager; - /** * MountPublicLinkController constructor. - * - * @param string $appName - * @param IRequest $request - * @param FederatedShareProvider $federatedShareProvider - * @param IManager $shareManager - * @param AddressHandler $addressHandler - * @param ISession $session - * @param IL10N $l - * @param IUserSession $userSession - * @param IClientService $clientService - * @param ICloudIdManager $cloudIdManager */ - public function __construct($appName, - IRequest $request, - FederatedShareProvider $federatedShareProvider, - IManager $shareManager, - AddressHandler $addressHandler, - ISession $session, - IL10N $l, - IUserSession $userSession, - IClientService $clientService, - ICloudIdManager $cloudIdManager + public function __construct( + string $appName, + IRequest $request, + private FederatedShareProvider $federatedShareProvider, + private IManager $shareManager, + private AddressHandler $addressHandler, + private ISession $session, + private IL10N $l, + private IUserSession $userSession, + private IClientService $clientService, + private ICloudIdManager $cloudIdManager, + private LoggerInterface $logger, ) { parent::__construct($appName, $request); - - $this->federatedShareProvider = $federatedShareProvider; - $this->shareManager = $shareManager; - $this->addressHandler = $addressHandler; - $this->session = $session; - $this->l = $l; - $this->userSession = $userSession; - $this->clientService = $clientService; - $this->cloudIdManager = $cloudIdManager; } /** @@ -175,9 +132,9 @@ class MountPublicLinkController extends Controller { try { $this->federatedShareProvider->create($share); } catch (\Exception $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::WARN, + $this->logger->warning($e->getMessage(), [ 'app' => 'federatedfilesharing', + 'exception' => $e, ]); return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index b4fedecfd42..6157bad0335 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -50,12 +50,12 @@ use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; -use OCP\ILogger; use OCP\IUserManager; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IShare; use OCP\Share\IShareProvider; +use Psr\Log\LoggerInterface; /** * Class FederatedShareProvider @@ -65,90 +65,29 @@ use OCP\Share\IShareProvider; class FederatedShareProvider implements IShareProvider { public const SHARE_TYPE_REMOTE = 6; - /** @var IDBConnection */ - private $dbConnection; - - /** @var AddressHandler */ - private $addressHandler; - - /** @var Notifications */ - private $notifications; - - /** @var TokenHandler */ - private $tokenHandler; - - /** @var IL10N */ - private $l; - - /** @var ILogger */ - private $logger; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IConfig */ - private $config; - /** @var string */ private $externalShareTable = 'share_external'; - /** @var IUserManager */ - private $userManager; - - /** @var ICloudIdManager */ - private $cloudIdManager; - - /** @var \OCP\GlobalScale\IConfig */ - private $gsConfig; - - /** @var ICloudFederationProviderManager */ - private $cloudFederationProviderManager; - /** @var array list of supported share types */ private $supportedShareType = [IShare::TYPE_REMOTE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_CIRCLE]; /** * DefaultShareProvider constructor. - * - * @param IDBConnection $connection - * @param AddressHandler $addressHandler - * @param Notifications $notifications - * @param TokenHandler $tokenHandler - * @param IL10N $l10n - * @param ILogger $logger - * @param IRootFolder $rootFolder - * @param IConfig $config - * @param IUserManager $userManager - * @param ICloudIdManager $cloudIdManager - * @param \OCP\GlobalScale\IConfig $globalScaleConfig - * @param ICloudFederationProviderManager $cloudFederationProviderManager */ public function __construct( - IDBConnection $connection, - AddressHandler $addressHandler, - Notifications $notifications, - TokenHandler $tokenHandler, - IL10N $l10n, - ILogger $logger, - IRootFolder $rootFolder, - IConfig $config, - IUserManager $userManager, - ICloudIdManager $cloudIdManager, - \OCP\GlobalScale\IConfig $globalScaleConfig, - ICloudFederationProviderManager $cloudFederationProviderManager + private IDBConnection $dbConnection, + private AddressHandler $addressHandler, + private Notifications $notifications, + private TokenHandler $tokenHandler, + private IL10N $l, + private IRootFolder $rootFolder, + private IConfig $config, + private IUserManager $userManager, + private ICloudIdManager $cloudIdManager, + private \OCP\GlobalScale\IConfig $gsConfig, + private ICloudFederationProviderManager $cloudFederationProviderManager, + private LoggerInterface $logger, ) { - $this->dbConnection = $connection; - $this->addressHandler = $addressHandler; - $this->notifications = $notifications; - $this->tokenHandler = $tokenHandler; - $this->l = $l10n; - $this->logger = $logger; - $this->rootFolder = $rootFolder; - $this->config = $config; - $this->userManager = $userManager; - $this->cloudIdManager = $cloudIdManager; - $this->gsConfig = $globalScaleConfig; - $this->cloudFederationProviderManager = $cloudFederationProviderManager; } /** @@ -303,10 +242,9 @@ class FederatedShareProvider implements IShareProvider { $failure = true; } } catch (\Exception $e) { - $this->logger->logException($e, [ - 'message' => 'Failed to notify remote server of federated share, removing share.', - 'level' => ILogger::ERROR, + $this->logger->error('Failed to notify remote server of federated share, removing share.', [ 'app' => 'federatedfilesharing', + 'exception' => $e, ]); $failure = true; } @@ -873,7 +811,6 @@ class FederatedShareProvider implements IShareProvider { * @throws ShareNotFound */ private function getRawShare($id) { - // Now fetch the inserted share and create a complete share object $qb = $this->dbConnection->getQueryBuilder(); $qb->select('*') diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index 2a162abcd76..f0d50a25abe 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -34,54 +34,22 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Http\Client\IClientService; -use OCP\ILogger; use OCP\OCS\IDiscoveryService; +use Psr\Log\LoggerInterface; class Notifications { public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls - /** @var AddressHandler */ - private $addressHandler; - - /** @var IClientService */ - private $httpClientService; - - /** @var IDiscoveryService */ - private $discoveryService; - - /** @var IJobList */ - private $jobList; - - /** @var ICloudFederationProviderManager */ - private $federationProviderManager; - - /** @var ICloudFederationFactory */ - private $cloudFederationFactory; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - /** @var ILogger */ - private $logger; - public function __construct( - AddressHandler $addressHandler, - IClientService $httpClientService, - IDiscoveryService $discoveryService, - ILogger $logger, - IJobList $jobList, - ICloudFederationProviderManager $federationProviderManager, - ICloudFederationFactory $cloudFederationFactory, - IEventDispatcher $eventDispatcher + private AddressHandler $addressHandler, + private IClientService $httpClientService, + private IDiscoveryService $discoveryService, + private IJobList $jobList, + private ICloudFederationProviderManager $federationProviderManager, + private ICloudFederationFactory $cloudFederationFactory, + private IEventDispatcher $eventDispatcher, + private LoggerInterface $logger, ) { - $this->addressHandler = $addressHandler; - $this->httpClientService = $httpClientService; - $this->discoveryService = $discoveryService; - $this->jobList = $jobList; - $this->logger = $logger; - $this->federationProviderManager = $federationProviderManager; - $this->cloudFederationFactory = $cloudFederationFactory; - $this->eventDispatcher = $eventDispatcher; } /** diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 5e2cafe0ce0..6ae334f1991 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -51,7 +51,6 @@ use OCP\HintException; use OCP\IConfig; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Notification\IManager as INotificationManager; @@ -60,117 +59,32 @@ use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; use OCP\Util; -use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; class CloudFederationProviderFiles implements ICloudFederationProvider { - - /** @var IAppManager */ - private $appManager; - - /** @var FederatedShareProvider */ - private $federatedShareProvider; - - /** @var AddressHandler */ - private $addressHandler; - - /** @var ILogger */ - private $logger; - - /** @var IUserManager */ - private $userManager; - - /** @var IManager */ - private $shareManager; - - /** @var ICloudIdManager */ - private $cloudIdManager; - - /** @var IActivityManager */ - private $activityManager; - - /** @var INotificationManager */ - private $notificationManager; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var ICloudFederationFactory */ - private $cloudFederationFactory; - - /** @var ICloudFederationProviderManager */ - private $cloudFederationProviderManager; - - /** @var IDBConnection */ - private $connection; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IConfig */ - private $config; - - /** @var Manager */ - private $externalShareManager; - /** * CloudFederationProvider constructor. - * - * @param IAppManager $appManager - * @param FederatedShareProvider $federatedShareProvider - * @param AddressHandler $addressHandler - * @param ILogger $logger - * @param IUserManager $userManager - * @param IManager $shareManager - * @param ICloudIdManager $cloudIdManager - * @param IActivityManager $activityManager - * @param INotificationManager $notificationManager - * @param IURLGenerator $urlGenerator - * @param ICloudFederationFactory $cloudFederationFactory - * @param ICloudFederationProviderManager $cloudFederationProviderManager - * @param IDBConnection $connection - * @param IGroupManager $groupManager - * @param IConfig $config - * @param Manager $externalShareManager */ public function __construct( - IAppManager $appManager, - FederatedShareProvider $federatedShareProvider, - AddressHandler $addressHandler, - ILogger $logger, - IUserManager $userManager, - IManager $shareManager, - ICloudIdManager $cloudIdManager, - IActivityManager $activityManager, - INotificationManager $notificationManager, - IURLGenerator $urlGenerator, - ICloudFederationFactory $cloudFederationFactory, - ICloudFederationProviderManager $cloudFederationProviderManager, - IDBConnection $connection, - IGroupManager $groupManager, - IConfig $config, - Manager $externalShareManager + private IAppManager $appManager, + private FederatedShareProvider $federatedShareProvider, + private AddressHandler $addressHandler, + private IUserManager $userManager, + private IManager $shareManager, + private ICloudIdManager $cloudIdManager, + private IActivityManager $activityManager, + private INotificationManager $notificationManager, + private IURLGenerator $urlGenerator, + private ICloudFederationFactory $cloudFederationFactory, + private ICloudFederationProviderManager $cloudFederationProviderManager, + private IDBConnection $connection, + private IGroupManager $groupManager, + private IConfig $config, + private Manager $externalShareManager, + private LoggerInterface $logger, ) { - $this->appManager = $appManager; - $this->federatedShareProvider = $federatedShareProvider; - $this->addressHandler = $addressHandler; - $this->logger = $logger; - $this->userManager = $userManager; - $this->shareManager = $shareManager; - $this->cloudIdManager = $cloudIdManager; - $this->activityManager = $activityManager; - $this->notificationManager = $notificationManager; - $this->urlGenerator = $urlGenerator; - $this->cloudFederationFactory = $cloudFederationFactory; - $this->cloudFederationProviderManager = $cloudFederationProviderManager; - $this->connection = $connection; - $this->groupManager = $groupManager; - $this->config = $config; - $this->externalShareManager = $externalShareManager; } - - /** * @return string */ @@ -239,18 +153,18 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); if (!$this->userManager->userExists($shareWith)) { - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); + throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST); } \OC_Util::setupFS($shareWith); } if ($shareType === IShare::TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { - throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); + throw new ProviderCouldNotAddShareException('Group does not exists', '', Http::STATUS_BAD_REQUEST); } try { - $this->externalShareManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); + $this->externalShareManager->addShare($remote, $token, '', $name, $owner, $shareType, false, $shareWith, $remoteId); $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); // get DisplayName about the owner of the share @@ -280,10 +194,9 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } return $shareId; } catch (\Exception $e) { - $this->logger->logException($e, [ - 'message' => 'Server can not add remote share.', - 'level' => ILogger::ERROR, - 'app' => 'files_sharing' + $this->logger->error('Server can not add remote share.', [ + 'app' => 'files_sharing', + 'exception' => $e, ]); throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); } diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index b04b7810910..7cc788d3a6c 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -48,48 +48,50 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IManager; use OCP\Share\IShare; +use Psr\Log\LoggerInterface; +use PHPUnit\Framework\MockObject\MockObject; class MountPublicLinkControllerTest extends \Test\TestCase { - /** @var IContactsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IContactsManager|MockObject */ protected $contactsManager; - /** @var MountPublicLinkController */ + /** @var MountPublicLinkController */ private $controller; - /** @var \OCP\IRequest | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|MockObject */ private $request; - /** @var FederatedShareProvider | \PHPUnit\Framework\MockObject\MockObject */ + /** @var FederatedShareProvider|MockObject */ private $federatedShareProvider; - /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IManager|MockObject */ private $shareManager; - /** @var AddressHandler | \PHPUnit\Framework\MockObject\MockObject */ + /** @var AddressHandler|MockObject */ private $addressHandler; - /** @var IRootFolder | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IRootFolder|MockObject */ private $rootFolder; - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|MockObject */ private $userManager; - /** @var ISession | \PHPUnit\Framework\MockObject\MockObject */ + /** @var ISession|MockObject */ private $session; - /** @var IL10N | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|MockObject */ private $l10n; - /** @var IUserSession | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|MockObject */ private $userSession; - /** @var IClientService | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IClientService|MockObject */ private $clientService; - /** @var IShare */ + /** @var IShare */ private $share; - /** @var ICloudIdManager */ + /** @var ICloudIdManager */ private $cloudIdManager; protected function setUp(): void { @@ -126,7 +128,8 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $this->l10n, $this->userSession, $this->clientService, - $this->cloudIdManager + $this->cloudIdManager, + $this->createMock(LoggerInterface::class), ); } diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 797d029d6b1..744cb769c54 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -47,12 +47,12 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Share\IManager; use OCP\Share\IShare; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; /** * Class FederatedShareProviderTest @@ -61,39 +61,38 @@ use PHPUnit\Framework\MockObject\MockObject; * @group DB */ class FederatedShareProviderTest extends \Test\TestCase { - /** @var IDBConnection */ protected $connection; - /** @var AddressHandler | \PHPUnit\Framework\MockObject\MockObject */ + /** @var AddressHandler|MockObject */ protected $addressHandler; - /** @var Notifications | \PHPUnit\Framework\MockObject\MockObject */ + /** @var Notifications|MockObject */ protected $notifications; - /** @var TokenHandler|\PHPUnit\Framework\MockObject\MockObject */ + /** @var TokenHandler|MockObject */ protected $tokenHandler; /** @var IL10N */ protected $l; - /** @var ILogger */ + /** @var LoggerInterface */ protected $logger; - /** @var IRootFolder | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IRootFolder|MockObject */ protected $rootFolder; - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|MockObject */ protected $config; - /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|MockObject */ protected $userManager; - /** @var \OCP\GlobalScale\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var \OCP\GlobalScale\IConfig|MockObject */ protected $gsConfig; /** @var IManager */ protected $shareManager; /** @var FederatedShareProvider */ protected $provider; - /** @var IContactsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IContactsManager|MockObject */ protected $contactsManager; /** @var ICloudIdManager */ private $cloudIdManager; - /** @var \PHPUnit\Framework\MockObject\MockObject|ICloudFederationProviderManager */ + /** @var MockObject|ICloudFederationProviderManager */ private $cloudFederationProviderManager; protected function setUp(): void { @@ -111,7 +110,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); - $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); @@ -137,13 +136,13 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->notifications, $this->tokenHandler, $this->l, - $this->logger, $this->rootFolder, $this->config, $this->userManager, $this->cloudIdManager, $this->gsConfig, - $this->cloudFederationProviderManager + $this->cloudFederationProviderManager, + $this->logger, ); $this->shareManager = \OC::$server->getShareManager(); @@ -476,13 +475,13 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->notifications, $this->tokenHandler, $this->l, - $this->logger, $this->rootFolder, $this->config, $this->userManager, $this->cloudIdManager, $this->gsConfig, - $this->cloudFederationProviderManager + $this->cloudFederationProviderManager, + $this->logger, ] )->setMethods(['sendPermissionUpdate'])->getMock(); diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php index c77d9affb17..e9027564d87 100644 --- a/apps/federatedfilesharing/tests/NotificationsTest.php +++ b/apps/federatedfilesharing/tests/NotificationsTest.php @@ -32,33 +32,33 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Http\Client\IClientService; -use OCP\ILogger; use OCP\OCS\IDiscoveryService; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class NotificationsTest extends \Test\TestCase { - - /** @var AddressHandler | \PHPUnit\Framework\MockObject\MockObject */ + /** @var AddressHandler|MockObject */ private $addressHandler; - /** @var IClientService | \PHPUnit\Framework\MockObject\MockObject*/ + /** @var IClientService|MockObject*/ private $httpClientService; - /** @var IDiscoveryService | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IDiscoveryService|MockObject */ private $discoveryService; - /** @var IJobList | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IJobList|MockObject */ private $jobList; - /** @var ICloudFederationProviderManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICloudFederationProviderManager|MockObject */ private $cloudFederationProviderManager; - /** @var ICloudFederationFactory|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICloudFederationFactory|MockObject */ private $cloudFederationFactory; - /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IEventDispatcher|MockObject */ private $eventDispatcher; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; protected function setUp(): void { @@ -69,7 +69,7 @@ class NotificationsTest extends \Test\TestCase { $this->httpClientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->getMock(); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') ->disableOriginalConstructor()->getMock(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); $this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); @@ -87,11 +87,11 @@ class NotificationsTest extends \Test\TestCase { $this->addressHandler, $this->httpClientService, $this->discoveryService, - $this->logger, $this->jobList, $this->cloudFederationProviderManager, $this->cloudFederationFactory, - $this->eventDispatcher + $this->eventDispatcher, + $this->logger, ); } else { $instance = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications') @@ -100,11 +100,11 @@ class NotificationsTest extends \Test\TestCase { $this->addressHandler, $this->httpClientService, $this->discoveryService, - $this->logger, $this->jobList, $this->cloudFederationProviderManager, $this->cloudFederationFactory, - $this->eventDispatcher + $this->eventDispatcher, + $this->logger, ] )->setMethods($mockedMethods)->getMock(); } diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 6abfb372a4d..8c01d660915 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -139,11 +139,11 @@ class ProviderFactory implements IProviderFactory { $addressHandler, $this->serverContainer->getHTTPClientService(), $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), - $this->serverContainer->getLogger(), $this->serverContainer->getJobList(), \OC::$server->getCloudFederationProviderManager(), \OC::$server->getCloudFederationFactory(), - $this->serverContainer->query(IEventDispatcher::class) + $this->serverContainer->query(IEventDispatcher::class), + $this->serverContainer->get(LoggerInterface::class), ); $tokenHandler = new TokenHandler( $this->serverContainer->getSecureRandom() @@ -155,13 +155,13 @@ class ProviderFactory implements IProviderFactory { $notifications, $tokenHandler, $l, - $this->serverContainer->getLogger(), $this->serverContainer->getLazyRootFolder(), $this->serverContainer->getConfig(), $this->serverContainer->getUserManager(), $this->serverContainer->getCloudIdManager(), $this->serverContainer->getGlobalScaleConfig(), - $this->serverContainer->getCloudFederationProviderManager() + $this->serverContainer->getCloudFederationProviderManager(), + $this->serverContainer->get(LoggerInterface::class), ); } -- 2.39.5