|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors |
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only |
|
|
|
|
@ -9,12 +10,15 @@ namespace Test\Preview; |
|
|
|
|
use OC\Preview\BackgroundCleanupJob; |
|
|
|
|
use OC\Preview\Storage\Root; |
|
|
|
|
use OC\PreviewManager; |
|
|
|
|
use OCP\App\IAppManager; |
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
|
|
|
|
use OCP\Files\File; |
|
|
|
|
use OCP\Files\IMimeTypeLoader; |
|
|
|
|
use OCP\Files\IRootFolder; |
|
|
|
|
use OCP\Files\NotFoundException; |
|
|
|
|
use OCP\IDBConnection; |
|
|
|
|
use OCP\IPreview; |
|
|
|
|
use OCP\Server; |
|
|
|
|
use Test\Traits\MountProviderTrait; |
|
|
|
|
use Test\Traits\UserTrait; |
|
|
|
|
|
|
|
|
|
@ -28,25 +32,12 @@ use Test\Traits\UserTrait; |
|
|
|
|
class BackgroundCleanupJobTest extends \Test\TestCase { |
|
|
|
|
use MountProviderTrait; |
|
|
|
|
use UserTrait; |
|
|
|
|
|
|
|
|
|
/** @var string */ |
|
|
|
|
private $userId; |
|
|
|
|
|
|
|
|
|
/** @var bool */ |
|
|
|
|
private $trashEnabled; |
|
|
|
|
|
|
|
|
|
/** @var IDBConnection */ |
|
|
|
|
private $connection; |
|
|
|
|
|
|
|
|
|
/** @var PreviewManager */ |
|
|
|
|
private $previewManager; |
|
|
|
|
|
|
|
|
|
/** @var IRootFolder */ |
|
|
|
|
private $rootFolder; |
|
|
|
|
|
|
|
|
|
/** @var IMimeTypeLoader */ |
|
|
|
|
private $mimeTypeLoader; |
|
|
|
|
|
|
|
|
|
private string $userId; |
|
|
|
|
private bool $trashEnabled; |
|
|
|
|
private IDBConnection $connection; |
|
|
|
|
private PreviewManager $previewManager; |
|
|
|
|
private IRootFolder $rootFolder; |
|
|
|
|
private IMimeTypeLoader $mimeTypeLoader; |
|
|
|
|
private ITimeFactory $timeFactory; |
|
|
|
|
|
|
|
|
|
protected function setUp(): void { |
|
|
|
|
@ -62,20 +53,20 @@ class BackgroundCleanupJobTest extends \Test\TestCase { |
|
|
|
|
$this->logout(); |
|
|
|
|
$this->loginAsUser($this->userId); |
|
|
|
|
|
|
|
|
|
$appManager = \OC::$server->getAppManager(); |
|
|
|
|
$appManager = Server::get(IAppManager::class); |
|
|
|
|
$this->trashEnabled = $appManager->isEnabledForUser('files_trashbin', $user); |
|
|
|
|
$appManager->disableApp('files_trashbin'); |
|
|
|
|
|
|
|
|
|
$this->connection = \OC::$server->getDatabaseConnection(); |
|
|
|
|
$this->previewManager = \OC::$server->getPreviewManager(); |
|
|
|
|
$this->rootFolder = \OC::$server->get(IRootFolder::class); |
|
|
|
|
$this->mimeTypeLoader = \OC::$server->getMimeTypeLoader(); |
|
|
|
|
$this->timeFactory = \OCP\Server::get(ITimeFactory::class); |
|
|
|
|
$this->connection = Server::get(IDBConnection::class); |
|
|
|
|
$this->previewManager = Server::get(IPreview::class); |
|
|
|
|
$this->rootFolder = Server::get(IRootFolder::class); |
|
|
|
|
$this->mimeTypeLoader = Server::get(IMimeTypeLoader::class); |
|
|
|
|
$this->timeFactory = Server::get(ITimeFactory::class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function tearDown(): void { |
|
|
|
|
if ($this->trashEnabled) { |
|
|
|
|
$appManager = \OC::$server->getAppManager(); |
|
|
|
|
$appManager = Server::get(IAppManager::class); |
|
|
|
|
$appManager->enableApp('files_trashbin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|