Files
nextcloud-server-mirror/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
Côme Chilliet 611180d728 chore: Replace $this->mocks[… by $this->getAutoMock(… in tests
This is clearer, safer and better typed.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-10-01 15:45:42 +02:00

52 lines
1.2 KiB
PHP

<?php
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
use OC\Repair\ClearGeneratedAvatarCache;
use OCP\IConfig;
class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
protected ClearGeneratedAvatarCache $repair;
#[\Override]
protected function setUp(): void {
parent::setUp();
$this->repair = $this->createInstanceWithMocks(ClearGeneratedAvatarCache::class);
}
public static function shouldRunDataProvider(): array {
return [
['11.0.0.0', true],
['15.0.0.3', true],
['13.0.5.2', true],
['12.0.0.0', true],
['26.0.0.1', true],
['15.0.0.2', true],
['13.0.0.0', true],
['27.0.0.5', false]
];
}
/**
*
* @param string $from
* @param boolean $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('shouldRunDataProvider')]
public function testShouldRun($from, $expected): void {
$this->getAutoMock(IConfig::class)->expects($this->any())
->method('getSystemValueString')
->with('version', '0.0.0.0')
->willReturn($from);
$this->assertEquals($expected, $this->invokePrivate($this->repair, 'shouldRun'));
}
}