ClearGeneratedAvatarCacheTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 OCP\Migration\IOutput;
  12. class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
  13. /** @var AvatarManager */
  14. private $avatarManager;
  15. /** @var IOutput */
  16. private $outputMock;
  17. /** @var IConfig */
  18. private $config;
  19. /** @var IJobList */
  20. private $jobList;
  21. protected ClearGeneratedAvatarCache $repair;
  22. protected function setUp(): void {
  23. parent::setUp();
  24. $this->outputMock = $this->createMock(IOutput::class);
  25. $this->avatarManager = $this->createMock(AvatarManager::class);
  26. $this->config = $this->createMock(IConfig::class);
  27. $this->jobList = $this->createMock(IJobList::class);
  28. $this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager, $this->jobList);
  29. }
  30. public function shouldRunDataProvider() {
  31. return [
  32. ['11.0.0.0', true],
  33. ['15.0.0.3', true],
  34. ['13.0.5.2', true],
  35. ['12.0.0.0', true],
  36. ['26.0.0.1', true],
  37. ['15.0.0.2', true],
  38. ['13.0.0.0', true],
  39. ['27.0.0.5', false]
  40. ];
  41. }
  42. /**
  43. * @dataProvider shouldRunDataProvider
  44. *
  45. * @param string $from
  46. * @param boolean $expected
  47. */
  48. public function testShouldRun($from, $expected): void {
  49. $this->config->expects($this->any())
  50. ->method('getSystemValueString')
  51. ->with('version', '0.0.0.0')
  52. ->willReturn($from);
  53. $this->assertEquals($expected, $this->invokePrivate($this->repair, 'shouldRun'));
  54. }
  55. }