2018-02-01 10:02:09 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2018-02-01 10:02:09 -05:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-02-01 10:02:09 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test\Repair;
|
2020-04-09 05:48:10 -04:00
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
use OC\Repair\ClearFrontendCaches;
|
2018-02-01 10:02:09 -05:00
|
|
|
use OC\Template\JSCombiner;
|
|
|
|
|
use OCP\ICache;
|
|
|
|
|
use OCP\ICacheFactory;
|
|
|
|
|
use OCP\Migration\IOutput;
|
2024-09-19 12:07:58 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-02-01 10:02:09 -05:00
|
|
|
|
|
|
|
|
class ClearFrontendCachesTest extends \Test\TestCase {
|
|
|
|
|
|
2024-09-19 12:07:58 -04:00
|
|
|
private ICacheFactory&MockObject $cacheFactory;
|
|
|
|
|
private JSCombiner&MockObject $jsCombiner;
|
|
|
|
|
private IOutput&MockObject $outputMock;
|
2018-02-01 10:02:09 -05:00
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
protected ClearFrontendCaches $repair;
|
2018-02-01 10:02:09 -05:00
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function setUp(): void {
|
2018-02-01 10:02:09 -05:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$this->outputMock = $this->createMock(IOutput::class);
|
|
|
|
|
|
|
|
|
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
|
|
|
|
$this->jsCombiner = $this->createMock(JSCombiner::class);
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->repair = new ClearFrontendCaches($this->cacheFactory, $this->jsCombiner);
|
2018-02-01 10:02:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testRun(): void {
|
2018-02-01 10:02:09 -05:00
|
|
|
$imagePathCache = $this->createMock(ICache::class);
|
|
|
|
|
$imagePathCache->expects($this->once())
|
|
|
|
|
->method('clear')
|
|
|
|
|
->with('');
|
|
|
|
|
$this->jsCombiner->expects($this->once())
|
|
|
|
|
->method('resetCache');
|
2022-08-29 10:36:40 -04:00
|
|
|
$this->cacheFactory->expects($this->once())
|
2018-02-01 10:02:09 -05:00
|
|
|
->method('createDistributed')
|
|
|
|
|
->with('imagePath')
|
|
|
|
|
->willReturn($imagePathCache);
|
|
|
|
|
|
|
|
|
|
$this->repair->run($this->outputMock);
|
|
|
|
|
$this->assertTrue(true);
|
|
|
|
|
}
|
|
|
|
|
}
|