|
| 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 | + |
| 24 | +namespace Test\Repair; |
| 25 | +use OC\Template\JSCombiner; |
| 26 | +use OC\Template\SCSSCacher; |
| 27 | +use OCP\ICache; |
| 28 | +use OCP\ICacheFactory; |
| 29 | +use OCP\Migration\IOutput; |
| 30 | + |
| 31 | +class ClearFrontendCachesTest extends \Test\TestCase { |
| 32 | + |
| 33 | + /** @var ICacheFactory */ |
| 34 | + private $cacheFactory; |
| 35 | + |
| 36 | + /** @var SCSSCacher */ |
| 37 | + private $scssCacher; |
| 38 | + |
| 39 | + /** @var JSCombiner */ |
| 40 | + private $jsCombiner; |
| 41 | + |
| 42 | + /** @var \OC\Repair\ClearFrontendCaches */ |
| 43 | + protected $repair; |
| 44 | + |
| 45 | + /** @var IOutput */ |
| 46 | + private $outputMock; |
| 47 | + |
| 48 | + protected function setUp() { |
| 49 | + parent::setUp(); |
| 50 | + |
| 51 | + $this->outputMock = $this->createMock(IOutput::class); |
| 52 | + |
| 53 | + $this->cacheFactory = $this->createMock(ICacheFactory::class); |
| 54 | + $this->scssCacher = $this->createMock(SCSSCacher::class); |
| 55 | + $this->jsCombiner = $this->createMock(JSCombiner::class); |
| 56 | + |
| 57 | + $this->repair = new \OC\Repair\ClearFrontendCaches($this->cacheFactory, $this->scssCacher, $this->jsCombiner); |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | + public function testRun() { |
| 62 | + $imagePathCache = $this->createMock(ICache::class); |
| 63 | + $imagePathCache->expects($this->once()) |
| 64 | + ->method('clear') |
| 65 | + ->with(''); |
| 66 | + $jsCache = $this->createMock(ICache::class); |
| 67 | + $jsCache->expects($this->once()) |
| 68 | + ->method('clear') |
| 69 | + ->with(''); |
| 70 | + $cssCache = $this->createMock(ICache::class); |
| 71 | + $cssCache->expects($this->once()) |
| 72 | + ->method('clear') |
| 73 | + ->with(''); |
| 74 | + $this->jsCombiner->expects($this->once()) |
| 75 | + ->method('resetCache'); |
| 76 | + $this->scssCacher->expects($this->once()) |
| 77 | + ->method('resetCache'); |
| 78 | + $this->cacheFactory->expects($this->at(0)) |
| 79 | + ->method('createDistributed') |
| 80 | + ->with('imagePath') |
| 81 | + ->willReturn($imagePathCache); |
| 82 | + $this->cacheFactory->expects($this->at(1)) |
| 83 | + ->method('createDistributed') |
| 84 | + ->with('SCSS') |
| 85 | + ->willReturn($cssCache); |
| 86 | + $this->cacheFactory->expects($this->at(2)) |
| 87 | + ->method('createDistributed') |
| 88 | + ->with('JS') |
| 89 | + ->willReturn($jsCache); |
| 90 | + |
| 91 | + $this->repair->run($this->outputMock); |
| 92 | + $this->assertTrue(true); |
| 93 | + } |
| 94 | +} |
0 commit comments