aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2025-07-03 08:41:40 +0200
committerJoas Schilling <coding@schilljs.com>2025-07-03 08:41:40 +0200
commit76045f1aa699d0dae69f4ed5d5ed0eef3bd36857 (patch)
tree9e63cd9defb7f98e5b8b5dd771311d259fec64d1
parent7383858a8f57dd64db7e2334b05b0a2b82dc1eaf (diff)
downloadnextcloud-server-bugfix/noid/background-job-testing.tar.gz
nextcloud-server-bugfix/noid/background-job-testing.zip
test(theming): Add unit test to check database query in theming backgroundjobbugfix/noid/background-job-testing
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/theming/tests/Jobs/RestoreBackgroundImageColorTest.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/apps/theming/tests/Jobs/RestoreBackgroundImageColorTest.php b/apps/theming/tests/Jobs/RestoreBackgroundImageColorTest.php
new file mode 100644
index 00000000000..cad412f7def
--- /dev/null
+++ b/apps/theming/tests/Jobs/RestoreBackgroundImageColorTest.php
@@ -0,0 +1,65 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\Theming\Tests\Jobs;
+
+use OCA\Theming\Jobs\RestoreBackgroundImageColor;
+use OCA\Theming\Service\BackgroundService;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\IJobList;
+use OCP\Files\IAppData;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
+use Test\TestCase;
+
+/**
+ * @group DB
+ */
+class RestoreBackgroundImageColorTest extends TestCase {
+
+ protected ITimeFactory&MockObject $time;
+ protected IConfig&MockObject $config;
+ protected IAppData&MockObject $appData;
+ protected IJobList&MockObject $jobList;
+ protected IDBConnection $dbc;
+ protected LoggerInterface&MockObject $logger;
+ protected BackgroundService&MockObject $service;
+ protected RestoreBackgroundImageColor $job;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->time = $this->createMock(ITimeFactory::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->appData = $this->createMock(IAppData::class);
+ $this->jobList = $this->createMock(IJobList::class);
+ $this->dbc = Server::get(IDBConnection::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
+ $this->service = $this->createMock(BackgroundService::class);
+ $this->job = new RestoreBackgroundImageColor(
+ $this->time,
+ $this->config,
+ $this->appData,
+ $this->jobList,
+ $this->dbc,
+ $this->logger,
+ $this->service,
+ );
+ }
+
+ public function testRunPreparation(): void {
+ $this->jobList->expects($this->once())
+ ->method('add')
+ ->with(RestoreBackgroundImageColor::class, ['stage' => RestoreBackgroundImageColor::STAGE_EXECUTE]);
+ self::invokePrivate($this->job, 'runPreparation');
+ }
+}