1
0

ClearFrontendCachesTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Template\JSCombiner;
  8. use OCP\ICache;
  9. use OCP\ICacheFactory;
  10. use OCP\Migration\IOutput;
  11. class ClearFrontendCachesTest extends \Test\TestCase {
  12. /** @var ICacheFactory */
  13. private $cacheFactory;
  14. /** @var JSCombiner */
  15. private $jsCombiner;
  16. /** @var \OC\Repair\ClearFrontendCaches */
  17. protected $repair;
  18. /** @var IOutput */
  19. private $outputMock;
  20. protected function setUp(): void {
  21. parent::setUp();
  22. $this->outputMock = $this->createMock(IOutput::class);
  23. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  24. $this->jsCombiner = $this->createMock(JSCombiner::class);
  25. $this->repair = new \OC\Repair\ClearFrontendCaches($this->cacheFactory, $this->jsCombiner);
  26. }
  27. public function testRun(): void {
  28. $imagePathCache = $this->createMock(ICache::class);
  29. $imagePathCache->expects($this->once())
  30. ->method('clear')
  31. ->with('');
  32. $this->jsCombiner->expects($this->once())
  33. ->method('resetCache');
  34. $this->cacheFactory->expects($this->once())
  35. ->method('createDistributed')
  36. ->with('imagePath')
  37. ->willReturn($imagePathCache);
  38. $this->repair->run($this->outputMock);
  39. $this->assertTrue(true);
  40. }
  41. }