aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-02-24 14:52:24 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2025-02-24 16:44:49 +0100
commitd3dbe3ab2c14760d4801c1167dc78d55943b9ebe (patch)
tree970dbe3bd517222ca2e797d8a8a9308d05193f96 /tests
parentbb73628ebeeb2e4adb2d90df3c7543e420ba0524 (diff)
downloadnextcloud-server-d3dbe3ab2c14760d4801c1167dc78d55943b9ebe.tar.gz
nextcloud-server-d3dbe3ab2c14760d4801c1167dc78d55943b9ebe.zip
refactor: convert sanitize account properties repair step to background jobbackport/50985/stable30
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php (renamed from tests/lib/Repair/NC29/ValidateAccountPropertiesTest.php)22
-rw-r--r--tests/lib/Repair/NC29/SanitizeAccountPropertiesTest.php43
2 files changed, 55 insertions, 10 deletions
diff --git a/tests/lib/Repair/NC29/ValidateAccountPropertiesTest.php b/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php
index e113f180998..e0f4eb3cbc1 100644
--- a/tests/lib/Repair/NC29/ValidateAccountPropertiesTest.php
+++ b/tests/lib/Repair/NC29/SanitizeAccountPropertiesJobTest.php
@@ -12,31 +12,36 @@ use InvalidArgumentException;
use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IUser;
use OCP\IUserManager;
-use OCP\Migration\IOutput;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
-class ValidateAccountPropertiesTest extends TestCase {
+class SanitizeAccountPropertiesJobTest extends TestCase {
private IUserManager&MockObject $userManager;
private IAccountManager&MockObject $accountManager;
private LoggerInterface&MockObject $logger;
- private ValidateAccountProperties $repairStep;
+ private SanitizeAccountPropertiesJob $job;
protected function setUp(): void {
$this->userManager = $this->createMock(IUserManager::class);
$this->accountManager = $this->createMock(IAccountManager::class);
$this->logger = $this->createMock(LoggerInterface::class);
- $this->repairStep = new ValidateAccountProperties($this->userManager, $this->accountManager, $this->logger);
+ $this->job = new SanitizeAccountPropertiesJob(
+ $this->createMock(ITimeFactory::class),
+ $this->userManager,
+ $this->accountManager,
+ $this->logger,
+ );
}
- public function testGetName(): void {
- self::assertStringContainsString('Validate account properties', $this->repairStep->getName());
+ public function testParallel() {
+ self::assertFalse($this->job->getAllowParallelRuns());
}
public function testRun(): void {
@@ -106,9 +111,6 @@ class ValidateAccountPropertiesTest extends TestCase {
}
});
- $output = $this->createMock(IOutput::class);
- $output->expects(self::once())->method('info')->with('Cleaned 1 invalid account property entries');
-
- $this->repairStep->run($output);
+ self::invokePrivate($this->job, 'run', [null]);
}
}
diff --git a/tests/lib/Repair/NC29/SanitizeAccountPropertiesTest.php b/tests/lib/Repair/NC29/SanitizeAccountPropertiesTest.php
new file mode 100644
index 00000000000..d0d33eb2817
--- /dev/null
+++ b/tests/lib/Repair/NC29/SanitizeAccountPropertiesTest.php
@@ -0,0 +1,43 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OC\Repair\NC29;
+
+use OCP\BackgroundJob\IJobList;
+use OCP\Migration\IOutput;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class SanitizeAccountPropertiesTest extends TestCase {
+
+ private IJobList&MockObject $jobList;
+ private SanitizeAccountProperties $repairStep;
+
+ protected function setUp(): void {
+ $this->jobList = $this->createMock(IJobList::class);
+
+ $this->repairStep = new SanitizeAccountProperties($this->jobList);
+ }
+
+ public function testGetName(): void {
+ self::assertStringContainsString('Validate account properties', $this->repairStep->getName());
+ }
+
+ public function testRun(): void {
+ $this->jobList->expects(self::once())
+ ->method('add')
+ ->with(SanitizeAccountPropertiesJob::class, null);
+
+ $output = $this->createMock(IOutput::class);
+ $output->expects(self::once())
+ ->method('info')
+ ->with(self::matchesRegularExpression('/queued background/i'));
+
+ $this->repairStep->run($output);
+ }
+}