diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-02-24 14:52:24 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-02-24 15:16:28 +0100 |
commit | e3af27b28018f36dc828dd9f60b06292386f6804 (patch) | |
tree | a2a7abb2f052234cda28f6dbac0cb7665e3066c1 /tests/lib/Repair | |
parent | 575222b5afd20a487ef07e7d08e1519fc07724ec (diff) | |
download | nextcloud-server-fix/account-property-validation.tar.gz nextcloud-server-fix/account-property-validation.zip |
refactor: convert sanitize account properties repair step to background jobfix/account-property-validation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests/lib/Repair')
-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.php | 43 |
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); + } +} |