ClearFrontendCachesTest.php 1.3 KB

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