1
0

ClearGeneratedAvatarCacheTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test\Repair;
  7. use OC\Avatar\AvatarManager;
  8. use OC\Repair\ClearGeneratedAvatarCache;
  9. use OCP\BackgroundJob\IJobList;
  10. use OCP\IConfig;
  11. use PHPUnit\Framework\MockObject\MockObject;
  12. class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
  13. private AvatarManager&MockObject $avatarManager;
  14. private IConfig&MockObject $config;
  15. private IJobList&MockObject $jobList;
  16. protected ClearGeneratedAvatarCache $repair;
  17. protected function setUp(): void {
  18. parent::setUp();
  19. $this->avatarManager = $this->createMock(AvatarManager::class);
  20. $this->config = $this->createMock(IConfig::class);
  21. $this->jobList = $this->createMock(IJobList::class);
  22. $this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager, $this->jobList);
  23. }
  24. public function shouldRunDataProvider() {
  25. return [
  26. ['11.0.0.0', true],
  27. ['15.0.0.3', true],
  28. ['13.0.5.2', true],
  29. ['12.0.0.0', true],
  30. ['26.0.0.1', true],
  31. ['15.0.0.2', true],
  32. ['13.0.0.0', true],
  33. ['27.0.0.5', false]
  34. ];
  35. }
  36. /**
  37. * @dataProvider shouldRunDataProvider
  38. *
  39. * @param string $from
  40. * @param boolean $expected
  41. */
  42. public function testShouldRun($from, $expected): void {
  43. $this->config->expects($this->any())
  44. ->method('getSystemValueString')
  45. ->with('version', '0.0.0.0')
  46. ->willReturn($from);
  47. $this->assertEquals($expected, $this->invokePrivate($this->repair, 'shouldRun'));
  48. }
  49. }