Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>pull/51005/head
parent
29e5e8a31b
commit
06ddb7aff6
@ -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.'); |
||||
} |
||||
} |
||||
@ -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); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue