Skip to content

Commit b2bfce2

Browse files
committed
Add tests and class mapping
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 60bf909 commit b2bfce2

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@
802802
'OC\\Repair' => $baseDir . '/lib/private/Repair.php',
803803
'OC\\RepairException' => $baseDir . '/lib/private/RepairException.php',
804804
'OC\\Repair\\CleanTags' => $baseDir . '/lib/private/Repair/CleanTags.php',
805+
'OC\\Repair\\ClearFrontendCaches' => $baseDir . '/lib/private/Repair/ClearFrontendCaches.php',
805806
'OC\\Repair\\Collation' => $baseDir . '/lib/private/Repair/Collation.php',
806807
'OC\\Repair\\MoveUpdaterStepFile' => $baseDir . '/lib/private/Repair/MoveUpdaterStepFile.php',
807808
'OC\\Repair\\NC11\\FixMountStorages' => $baseDir . '/lib/private/Repair/NC11/FixMountStorages.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
832832
'OC\\Repair' => __DIR__ . '/../../..' . '/lib/private/Repair.php',
833833
'OC\\RepairException' => __DIR__ . '/../../..' . '/lib/private/RepairException.php',
834834
'OC\\Repair\\CleanTags' => __DIR__ . '/../../..' . '/lib/private/Repair/CleanTags.php',
835+
'OC\\Repair\\ClearFrontendCaches' => __DIR__ . '/../../..' . '/lib/private/Repair/ClearFrontendCaches.php',
835836
'OC\\Repair\\Collation' => __DIR__ . '/../../..' . '/lib/private/Repair/Collation.php',
836837
'OC\\Repair\\MoveUpdaterStepFile' => __DIR__ . '/../../..' . '/lib/private/Repair/MoveUpdaterStepFile.php',
837838
'OC\\Repair\\NC11\\FixMountStorages' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/FixMountStorages.php',
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

Comments
 (0)