1
0

ClearFrontendCachesTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  4. *
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace Test\Repair;
  24. use OC\Template\JSCombiner;
  25. use OCP\ICache;
  26. use OCP\ICacheFactory;
  27. use OCP\Migration\IOutput;
  28. class ClearFrontendCachesTest extends \Test\TestCase {
  29. /** @var ICacheFactory */
  30. private $cacheFactory;
  31. /** @var JSCombiner */
  32. private $jsCombiner;
  33. /** @var \OC\Repair\ClearFrontendCaches */
  34. protected $repair;
  35. /** @var IOutput */
  36. private $outputMock;
  37. protected function setUp(): void {
  38. parent::setUp();
  39. $this->outputMock = $this->createMock(IOutput::class);
  40. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  41. $this->jsCombiner = $this->createMock(JSCombiner::class);
  42. $this->repair = new \OC\Repair\ClearFrontendCaches($this->cacheFactory, $this->jsCombiner);
  43. }
  44. public function testRun() {
  45. $imagePathCache = $this->createMock(ICache::class);
  46. $imagePathCache->expects($this->once())
  47. ->method('clear')
  48. ->with('');
  49. $this->jsCombiner->expects($this->once())
  50. ->method('resetCache');
  51. $this->cacheFactory->expects($this->once())
  52. ->method('createDistributed')
  53. ->with('imagePath')
  54. ->willReturn($imagePathCache);
  55. $this->repair->run($this->outputMock);
  56. $this->assertTrue(true);
  57. }
  58. }