use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
-use OCP\IServerContainer;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
/**
*/
class ShareAPIController extends OCSController {
- /** @var IManager */
- private $shareManager;
- /** @var IGroupManager */
- private $groupManager;
- /** @var IUserManager */
- private $userManager;
- /** @var IRootFolder */
- private $rootFolder;
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var string */
- private $currentUser;
- /** @var IL10N */
- private $l;
- /** @var \OCP\Files\Node */
- private $lockedNode;
- /** @var IConfig */
- private $config;
- /** @var IAppManager */
- private $appManager;
- /** @var IServerContainer */
- private $serverContainer;
- /** @var IUserStatusManager */
- private $userStatusManager;
- /** @var IPreview */
- private $previewManager;
+ private ?Node $lockedNode = null;
+ private string $currentUser;
/**
* Share20OCS constructor.
public function __construct(
string $appName,
IRequest $request,
- IManager $shareManager,
- IGroupManager $groupManager,
- IUserManager $userManager,
- IRootFolder $rootFolder,
- IURLGenerator $urlGenerator,
- string $userId = null,
- IL10N $l10n,
- IConfig $config,
- IAppManager $appManager,
- IServerContainer $serverContainer,
- IUserStatusManager $userStatusManager,
- IPreview $previewManager,
+ private IManager $shareManager,
+ private IGroupManager $groupManager,
+ private IUserManager $userManager,
+ private IRootFolder $rootFolder,
+ private IURLGenerator $urlGenerator,
+ private IL10N $l,
+ private IConfig $config,
+ private IAppManager $appManager,
+ private ContainerInterface $serverContainer,
+ private IUserStatusManager $userStatusManager,
+ private IPreview $previewManager,
private IDateTimeZone $dateTimeZone,
+ private LoggerInterface $logger,
+ ?string $userId = null
) {
parent::__construct($appName, $request);
-
- $this->shareManager = $shareManager;
- $this->userManager = $userManager;
- $this->groupManager = $groupManager;
- $this->request = $request;
- $this->rootFolder = $rootFolder;
- $this->urlGenerator = $urlGenerator;
$this->currentUser = $userId;
- $this->l = $l10n;
- $this->config = $config;
- $this->appManager = $appManager;
- $this->serverContainer = $serverContainer;
- $this->userStatusManager = $userStatusManager;
- $this->previewManager = $previewManager;
}
/**
'strict_search' => true,
]);
} catch (Exception $e) {
- Server::get(LoggerInterface::class)->error(
+ $this->logger->error(
$e->getMessage(),
['exception' => $e]
);
try {
$slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
} catch (\Throwable $e) {
- Server::get(LoggerInterface::class)->error(
+ $this->logger->error(
$e->getMessage(),
['exception' => $e]
);
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
-use OCP\IServerContainer;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
+use Psr\Container\ContainerInterface;
+use Psr\Log\LoggerInterface;
/**
* Class ApiTest
});
$config = $this->createMock(IConfig::class);
$appManager = $this->createMock(IAppManager::class);
- $serverContainer = $this->createMock(IServerContainer::class);
+ $serverContainer = $this->createMock(ContainerInterface::class);
$userStatusManager = $this->createMock(IUserStatusManager::class);
$previewManager = $this->createMock(IPreview::class);
$dateTimeZone = $this->createMock(IDateTimeZone::class);
+ $logger = $this->createMock(LoggerInterface::class);
$dateTimeZone->method('getTimeZone')->willReturn(new \DateTimeZone(date_default_timezone_get()));
return new ShareAPIController(
\OC::$server->getUserManager(),
\OC::$server->getRootFolder(),
\OC::$server->getURLGenerator(),
- $userId,
$l,
$config,
$appManager,
$userStatusManager,
$previewManager,
$dateTimeZone,
+ $logger,
+ $userId,
);
}
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
-use OCP\IServerContainer;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
*/
class ShareAPIControllerTest extends TestCase {
- /** @var string */
- private $appName = 'files_sharing';
-
- /** @var \OC\Share20\Manager|\PHPUnit\Framework\MockObject\MockObject */
- private $shareManager;
-
- /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
- private $groupManager;
-
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
- private $userManager;
-
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
-
- /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
- private $rootFolder;
-
- /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
- private $urlGenerator;
-
- /** @var string|\PHPUnit\Framework\MockObject\MockObject */
- private $currentUser;
-
- /** @var ShareAPIController */
- private $ocs;
-
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
- private $l;
-
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- private $config;
-
- /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
- private $appManager;
-
- /** @var IServerContainer|\PHPUnit\Framework\MockObject\MockObject */
- private $serverContainer;
-
- /** @var IUserStatusManager|\PHPUnit\Framework\MockObject\MockObject */
- private $userStatusManager;
-
- /** @var IPreview|\PHPUnit\Framework\MockObject\MockObject */
- private $previewManager;
-
- /** @var IDateTimeZone|\PHPUnit\Framework\MockObject\MockObject */
- private $dateTimeZone;
+ private string $appName = 'files_sharing';
+ private \OC\Share20\Manager|\PHPUnit\Framework\MockObject\MockObject $shareManager;
+ private IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager;
+ private IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager;
+ private IRequest|\PHPUnit\Framework\MockObject\MockObject $request;
+ private IRootFolder|\PHPUnit\Framework\MockObject\MockObject $rootFolder;
+ private IURLGenerator|\PHPUnit\Framework\MockObject\MockObject $urlGenerator;
+ private string|\PHPUnit\Framework\MockObject\MockObject $currentUser;
+ private ShareAPIController $ocs;
+ private IL10N|\PHPUnit\Framework\MockObject\MockObject $l;
+ private IConfig|\PHPUnit\Framework\MockObject\MockObject $config;
+ private IAppManager|\PHPUnit\Framework\MockObject\MockObject $appManager;
+ private IServerContainer|\PHPUnit\Framework\MockObject\MockObject $serverContainer;
+ private IUserStatusManager|\PHPUnit\Framework\MockObject\MockObject $userStatusManager;
+ private IPreview|\PHPUnit\Framework\MockObject\MockObject $previewManager;
+ private IDateTimeZone|\PHPUnit\Framework\MockObject\MockObject $dateTimeZone;
+ private LoggerInterface $logger;
protected function setUp(): void {
$this->shareManager = $this->createMock(IManager::class);
});
$this->config = $this->createMock(IConfig::class);
$this->appManager = $this->createMock(IAppManager::class);
- $this->serverContainer = $this->createMock(IServerContainer::class);
+ $this->serverContainer = $this->createMock(ContainerInterface::class);
$this->userStatusManager = $this->createMock(IUserStatusManager::class);
$this->previewManager = $this->createMock(IPreview::class);
$this->previewManager->method('isAvailable')
return $fileInfo->getMimeType() === 'mimeWithPreview';
});
$this->dateTimeZone = $this->createMock(IDateTimeZone::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->ocs = new ShareAPIController(
$this->appName,
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
);
}
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
}
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
+
])->setMethods(['canAccessShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();
$this->userManager,
$this->rootFolder,
$this->urlGenerator,
- $this->currentUser,
$this->l,
$this->config,
$this->appManager,
$this->userStatusManager,
$this->previewManager,
$this->dateTimeZone,
+ $this->logger,
+ $this->currentUser,
])->setMethods(['formatShare'])
->getMock();