Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>tags/v26.0.0beta1
@@ -24,6 +24,7 @@ | |||
namespace OCA\Files\Tests\BackgroundJob; | |||
use OCA\Files\BackgroundJob\DeleteOrphanedItems; | |||
use OCP\AppFramework\Utility\ITimeFactory; | |||
use OCP\DB\QueryBuilder\IQueryBuilder; | |||
/** | |||
@@ -34,13 +35,15 @@ use OCP\DB\QueryBuilder\IQueryBuilder; | |||
* @package Test\BackgroundJob | |||
*/ | |||
class DeleteOrphanedItemsJobTest extends \Test\TestCase { | |||
/** @var \OCP\IDBConnection */ | |||
protected $connection; | |||
protected ITimeFactory $timeFactory; | |||
protected function setUp(): void { | |||
parent::setUp(); | |||
$this->connection = \OC::$server->getDatabaseConnection(); | |||
$this->timeFactory = $this->createMock(ITimeFactory::class); | |||
} | |||
protected function cleanMapping($table) { | |||
@@ -95,7 +98,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase { | |||
$mapping = $this->getMappings('systemtag_object_mapping'); | |||
$this->assertCount(2, $mapping); | |||
$job = new DeleteOrphanedItems(); | |||
$job = new DeleteOrphanedItems($this->timeFactory); | |||
$this->invokePrivate($job, 'cleanSystemTags'); | |||
$mapping = $this->getMappings('systemtag_object_mapping'); | |||
@@ -144,7 +147,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase { | |||
$mapping = $this->getMappings('vcategory_to_object'); | |||
$this->assertCount(2, $mapping); | |||
$job = new DeleteOrphanedItems(); | |||
$job = new DeleteOrphanedItems($this->timeFactory); | |||
$this->invokePrivate($job, 'cleanUserTags'); | |||
$mapping = $this->getMappings('vcategory_to_object'); | |||
@@ -195,7 +198,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase { | |||
$mapping = $this->getMappings('comments'); | |||
$this->assertCount(2, $mapping); | |||
$job = new DeleteOrphanedItems(); | |||
$job = new DeleteOrphanedItems($this->timeFactory); | |||
$this->invokePrivate($job, 'cleanComments'); | |||
$mapping = $this->getMappings('comments'); | |||
@@ -244,7 +247,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase { | |||
$mapping = $this->getMappings('comments_read_markers'); | |||
$this->assertCount(2, $mapping); | |||
$job = new DeleteOrphanedItems(); | |||
$job = new DeleteOrphanedItems($this->timeFactory); | |||
$this->invokePrivate($job, 'cleanCommentMarkers'); | |||
$mapping = $this->getMappings('comments_read_markers'); |
@@ -27,6 +27,7 @@ | |||
namespace OCA\Files_Sharing\Tests; | |||
use OCA\Files_Sharing\DeleteOrphanedSharesJob; | |||
use OCP\AppFramework\Utility\ITimeFactory; | |||
use OCP\Share\IShare; | |||
/** | |||
@@ -37,7 +38,6 @@ use OCP\Share\IShare; | |||
* @package OCA\Files_Sharing\Tests | |||
*/ | |||
class DeleteOrphanedSharesJobTest extends \Test\TestCase { | |||
/** | |||
* @var bool | |||
*/ | |||
@@ -94,7 +94,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { | |||
\OC::registerShareHooks(\OC::$server->getSystemConfig()); | |||
$this->job = new DeleteOrphanedSharesJob(); | |||
$this->job = new DeleteOrphanedSharesJob(\OCP\Server::get(ITimeFactory::class)); | |||
} | |||
protected function tearDown(): void { |
@@ -25,6 +25,7 @@ namespace Test\Preview; | |||
use OC\Preview\BackgroundCleanupJob; | |||
use OC\Preview\Storage\Root; | |||
use OC\PreviewManager; | |||
use OCP\AppFramework\Utility\ITimeFactory; | |||
use OCP\Files\File; | |||
use OCP\Files\IMimeTypeLoader; | |||
use OCP\Files\IRootFolder; | |||
@@ -62,6 +63,8 @@ class BackgroundCleanupJobTest extends \Test\TestCase { | |||
/** @var IMimeTypeLoader */ | |||
private $mimeTypeLoader; | |||
private ITimeFactory $timeFactory; | |||
protected function setUp(): void { | |||
parent::setUp(); | |||
@@ -83,6 +86,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase { | |||
$this->previewManager = \OC::$server->getPreviewManager(); | |||
$this->rootFolder = \OC::$server->getRootFolder(); | |||
$this->mimeTypeLoader = \OC::$server->getMimeTypeLoader(); | |||
$this->timeFactory = \OCP\Server::get(ITimeFactory::class); | |||
} | |||
protected function tearDown(): void { | |||
@@ -142,7 +146,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase { | |||
$root = $this->getRoot(); | |||
$this->assertSame(11, $this->countPreviews($root, $fileIds)); | |||
$job = new BackgroundCleanupJob($this->connection, $root, $this->mimeTypeLoader, true); | |||
$job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $root, $this->mimeTypeLoader, true); | |||
$job->run([]); | |||
foreach ($files as $file) { | |||
@@ -166,7 +170,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase { | |||
$root = $this->getRoot(); | |||
$this->assertSame(11, $this->countPreviews($root, $fileIds)); | |||
$job = new BackgroundCleanupJob($this->connection, $root, $this->mimeTypeLoader, false); | |||
$job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $root, $this->mimeTypeLoader, false); | |||
$job->run([]); | |||
foreach ($files as $file) { | |||
@@ -196,7 +200,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase { | |||
$appdata = \OC::$server->getAppDataDir('preview'); | |||
$this->assertSame(2, count($appdata->getDirectoryListing())); | |||
$job = new BackgroundCleanupJob($this->connection, $this->getRoot(), $this->mimeTypeLoader, true); | |||
$job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $this->getRoot(), $this->mimeTypeLoader, true); | |||
$job->run([]); | |||
$appdata = \OC::$server->getAppDataDir('preview'); |