-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: convert sanitize account properties repair step to backgrou…
…nd job Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
7 changed files
with
100 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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 OCP\Migration\IRepairStep; | ||
|
||
class SanitizeAccountProperties implements IRepairStep { | ||
|
||
public function __construct( | ||
private IJobList $jobList, | ||
) { | ||
} | ||
|
||
public function getName(): string { | ||
return 'Validate account properties and store phone numbers in a known format for search'; | ||
} | ||
|
||
public function run(IOutput $output): void { | ||
$this->jobList->add(SanitizeAccountPropertiesJob::class, null); | ||
$output->info('Queued background to validate account properties.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |