You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SCSSCacherTest.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 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\Template;
  24. use OC\AppConfig;
  25. use OC\Files\AppData\AppData;
  26. use OC\Files\AppData\Factory;
  27. use OC\Template\IconsCacher;
  28. use OC\Template\SCSSCacher;
  29. use OCA\Theming\ThemingDefaults;
  30. use OCP\AppFramework\Utility\ITimeFactory;
  31. use OCP\Files\IAppData;
  32. use OCP\Files\NotFoundException;
  33. use OCP\Files\SimpleFS\ISimpleFile;
  34. use OCP\Files\SimpleFS\ISimpleFolder;
  35. use OCP\ICache;
  36. use OCP\ICacheFactory;
  37. use OCP\IConfig;
  38. use OCP\ILogger;
  39. use OCP\IURLGenerator;
  40. class SCSSCacherTest extends \Test\TestCase {
  41. /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
  42. protected $logger;
  43. /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
  44. protected $appData;
  45. /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
  46. protected $urlGenerator;
  47. /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
  48. protected $config;
  49. /** @var ThemingDefaults|\PHPUnit\Framework\MockObject\MockObject */
  50. protected $themingDefaults;
  51. /** @var SCSSCacher */
  52. protected $scssCacher;
  53. /** @var ICache|\PHPUnit\Framework\MockObject\MockObject */
  54. protected $depsCache;
  55. /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
  56. protected $cacheFactory;
  57. /** @var IconsCacher|\PHPUnit\Framework\MockObject\MockObject */
  58. protected $iconsCacher;
  59. /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
  60. protected $timeFactory;
  61. /** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */
  62. protected $appConfig;
  63. protected function setUp(): void {
  64. parent::setUp();
  65. $this->logger = $this->createMock(ILogger::class);
  66. $this->appData = $this->createMock(AppData::class);
  67. $this->iconsCacher = $this->createMock(IconsCacher::class);
  68. $this->timeFactory = $this->createMock(ITimeFactory::class);
  69. /** @var Factory|\PHPUnit\Framework\MockObject\MockObject $factory */
  70. $factory = $this->createMock(Factory::class);
  71. $factory->method('get')->with('css')->willReturn($this->appData);
  72. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  73. $this->urlGenerator->expects($this->any())
  74. ->method('getBaseUrl')
  75. ->willReturn('http://localhost/nextcloud');
  76. $this->config = $this->createMock(IConfig::class);
  77. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  78. $this->depsCache = $this->createMock(ICache::class);
  79. $this->cacheFactory->expects($this->at(0))
  80. ->method('createDistributed')
  81. ->willReturn($this->depsCache);
  82. $this->themingDefaults = $this->createMock(ThemingDefaults::class);
  83. $this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]);
  84. $iconsFile = $this->createMock(ISimpleFile::class);
  85. $this->iconsCacher->expects($this->any())
  86. ->method('getCachedCSS')
  87. ->willReturn($iconsFile);
  88. $this->appConfig = $this->createMock(AppConfig::class);
  89. $this->scssCacher = new SCSSCacher(
  90. $this->logger,
  91. $factory,
  92. $this->urlGenerator,
  93. $this->config,
  94. $this->themingDefaults,
  95. \OC::$SERVERROOT,
  96. $this->cacheFactory,
  97. $this->iconsCacher,
  98. $this->timeFactory,
  99. $this->appConfig
  100. );
  101. }
  102. public function testProcessUncachedFileNoAppDataFolder() {
  103. $folder = $this->createMock(ISimpleFolder::class);
  104. $file = $this->createMock(ISimpleFile::class);
  105. $file->expects($this->any())->method('getSize')->willReturn(1);
  106. $this->appData->expects($this->once())->method('getFolder')->with('core')->willThrowException(new NotFoundException());
  107. $this->appData->expects($this->once())->method('newFolder')->with('core')->willReturn($folder);
  108. $this->appData->method('getDirectoryListing')->willReturn([]);
  109. $fileDeps = $this->createMock(ISimpleFile::class);
  110. $gzfile = $this->createMock(ISimpleFile::class);
  111. $filePrefix = substr(md5(\OC_Util::getVersionString('core')), 0, 4) . '-' .
  112. substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-';
  113. $folder->method('getFile')
  114. ->willReturnCallback(function ($path) use ($file, $gzfile, $filePrefix) {
  115. if ($path === $filePrefix.'styles.css') {
  116. return $file;
  117. } elseif ($path === $filePrefix.'styles.css.deps') {
  118. throw new NotFoundException();
  119. } elseif ($path === $filePrefix.'styles.css.gzip') {
  120. return $gzfile;
  121. } else {
  122. $this->fail();
  123. }
  124. });
  125. $folder->expects($this->once())
  126. ->method('newFile')
  127. ->with($filePrefix.'styles.css.deps')
  128. ->willReturn($fileDeps);
  129. $this->urlGenerator->expects($this->once())
  130. ->method('getBaseUrl')
  131. ->willReturn('http://localhost/nextcloud');
  132. $this->iconsCacher->expects($this->any())
  133. ->method('setIconsCss')
  134. ->willReturn('scss {}');
  135. $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
  136. $this->assertTrue($actual);
  137. }
  138. public function testProcessUncachedFile() {
  139. $folder = $this->createMock(ISimpleFolder::class);
  140. $this->appData->expects($this->once())->method('getFolder')->with('core')->willReturn($folder);
  141. $this->appData->method('getDirectoryListing')->willReturn([]);
  142. $file = $this->createMock(ISimpleFile::class);
  143. $file->expects($this->any())->method('getSize')->willReturn(1);
  144. $fileDeps = $this->createMock(ISimpleFile::class);
  145. $gzfile = $this->createMock(ISimpleFile::class);
  146. $filePrefix = substr(md5(\OC_Util::getVersionString('core')), 0, 4) . '-' .
  147. substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-';
  148. $folder->method('getFile')
  149. ->willReturnCallback(function ($path) use ($file, $gzfile, $filePrefix) {
  150. if ($path === $filePrefix.'styles.css') {
  151. return $file;
  152. } elseif ($path === $filePrefix.'styles.css.deps') {
  153. throw new NotFoundException();
  154. } elseif ($path === $filePrefix.'styles.css.gzip') {
  155. return $gzfile;
  156. } else {
  157. $this->fail();
  158. }
  159. });
  160. $folder->expects($this->once())
  161. ->method('newFile')
  162. ->with($filePrefix.'styles.css.deps')
  163. ->willReturn($fileDeps);
  164. $this->iconsCacher->expects($this->any())
  165. ->method('setIconsCss')
  166. ->willReturn('scss {}');
  167. $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
  168. $this->assertTrue($actual);
  169. }
  170. public function testProcessCachedFile() {
  171. $folder = $this->createMock(ISimpleFolder::class);
  172. $this->appData->expects($this->once())->method('getFolder')->with('core')->willReturn($folder);
  173. $this->appData->method('getDirectoryListing')->willReturn([]);
  174. $file = $this->createMock(ISimpleFile::class);
  175. $fileDeps = $this->createMock(ISimpleFile::class);
  176. $fileDeps->expects($this->any())->method('getSize')->willReturn(1);
  177. $gzFile = $this->createMock(ISimpleFile::class);
  178. $filePrefix = substr(md5(\OC_Util::getVersionString('core')), 0, 4) . '-' .
  179. substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-';
  180. $folder->method('getFile')
  181. ->willReturnCallback(function ($name) use ($file, $fileDeps, $gzFile, $filePrefix) {
  182. if ($name === $filePrefix.'styles.css') {
  183. return $file;
  184. } elseif ($name === $filePrefix.'styles.css.deps') {
  185. return $fileDeps;
  186. } elseif ($name === $filePrefix.'styles.css.gzip') {
  187. return $gzFile;
  188. }
  189. $this->fail();
  190. });
  191. $this->iconsCacher->expects($this->any())
  192. ->method('setIconsCss')
  193. ->willReturn('scss {}');
  194. $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
  195. $this->assertTrue($actual);
  196. }
  197. public function testProcessCachedFileMemcache() {
  198. $folder = $this->createMock(ISimpleFolder::class);
  199. $this->appData->expects($this->once())
  200. ->method('getFolder')
  201. ->with('core')
  202. ->willReturn($folder);
  203. $folder->method('getName')
  204. ->willReturn('core');
  205. $this->appData->method('getDirectoryListing')->willReturn([]);
  206. $file = $this->createMock(ISimpleFile::class);
  207. $fileDeps = $this->createMock(ISimpleFile::class);
  208. $fileDeps->expects($this->any())->method('getSize')->willReturn(1);
  209. $gzFile = $this->createMock(ISimpleFile::class);
  210. $filePrefix = substr(md5(\OC_Util::getVersionString('core')), 0, 4) . '-' .
  211. substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-';
  212. $folder->method('getFile')
  213. ->willReturnCallback(function ($name) use ($file, $fileDeps, $gzFile, $filePrefix) {
  214. if ($name === $filePrefix.'styles.css') {
  215. return $file;
  216. } elseif ($name === $filePrefix.'styles.css.deps') {
  217. return $fileDeps;
  218. } elseif ($name === $filePrefix.'styles.css.gzip') {
  219. return $gzFile;
  220. }
  221. $this->fail();
  222. });
  223. $this->iconsCacher->expects($this->any())
  224. ->method('setIconsCss')
  225. ->willReturn('scss {}');
  226. $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
  227. $this->assertTrue($actual);
  228. }
  229. public function testIsCachedNoFile() {
  230. $fileNameCSS = "styles.css";
  231. $folder = $this->createMock(ISimpleFolder::class);
  232. $folder->expects($this->at(0))->method('getFile')->with($fileNameCSS)->willThrowException(new NotFoundException());
  233. $this->appData->expects($this->any())
  234. ->method('getFolder')
  235. ->willReturn($folder);
  236. $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, 'core']);
  237. $this->assertFalse($actual);
  238. }
  239. public function testIsCachedNoDepsFile() {
  240. $fileNameCSS = "styles.css";
  241. $folder = $this->createMock(ISimpleFolder::class);
  242. $file = $this->createMock(ISimpleFile::class);
  243. $file->expects($this->once())->method('getSize')->willReturn(1);
  244. $folder->method('getFile')
  245. ->willReturnCallback(function ($path) use ($file) {
  246. if ($path === 'styles.css') {
  247. return $file;
  248. } elseif ($path === 'styles.css.deps') {
  249. throw new NotFoundException();
  250. } else {
  251. $this->fail();
  252. }
  253. });
  254. $this->appData->expects($this->any())
  255. ->method('getFolder')
  256. ->willReturn($folder);
  257. $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, 'core']);
  258. $this->assertFalse($actual);
  259. }
  260. public function testCacheNoFile() {
  261. $fileNameCSS = "styles.css";
  262. $fileNameSCSS = "styles.scss";
  263. $folder = $this->createMock(ISimpleFolder::class);
  264. $file = $this->createMock(ISimpleFile::class);
  265. $depsFile = $this->createMock(ISimpleFile::class);
  266. $gzipFile = $this->createMock(ISimpleFile::class);
  267. $webDir = "core/css";
  268. $path = \OC::$SERVERROOT . '/core/css/';
  269. $folder->method('getFile')->willThrowException(new NotFoundException());
  270. $folder->method('newFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) {
  271. if ($fileName === 'styles.css') {
  272. return $file;
  273. } elseif ($fileName === 'styles.css.deps') {
  274. return $depsFile;
  275. } elseif ($fileName === 'styles.css.gzip') {
  276. return $gzipFile;
  277. }
  278. throw new \Exception();
  279. });
  280. $this->iconsCacher->expects($this->any())
  281. ->method('setIconsCss')
  282. ->willReturn('scss {}');
  283. $file->expects($this->once())->method('putContent');
  284. $depsFile->expects($this->once())->method('putContent');
  285. $gzipFile->expects($this->once())->method('putContent');
  286. $actual = self::invokePrivate($this->scssCacher, 'cache', [$path, $fileNameCSS, $fileNameSCSS, $folder, $webDir]);
  287. $this->assertTrue($actual);
  288. }
  289. public function testCache() {
  290. $fileNameCSS = "styles.css";
  291. $fileNameSCSS = "styles.scss";
  292. $folder = $this->createMock(ISimpleFolder::class);
  293. $file = $this->createMock(ISimpleFile::class);
  294. $depsFile = $this->createMock(ISimpleFile::class);
  295. $gzipFile = $this->createMock(ISimpleFile::class);
  296. $webDir = "core/css";
  297. $path = \OC::$SERVERROOT;
  298. $folder->method('getFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) {
  299. if ($fileName === 'styles.css') {
  300. return $file;
  301. } elseif ($fileName === 'styles.css.deps') {
  302. return $depsFile;
  303. } elseif ($fileName === 'styles.css.gzip') {
  304. return $gzipFile;
  305. }
  306. throw new \Exception();
  307. });
  308. $file->expects($this->once())->method('putContent');
  309. $depsFile->expects($this->once())->method('putContent');
  310. $gzipFile->expects($this->once())->method('putContent');
  311. $this->iconsCacher->expects($this->any())
  312. ->method('setIconsCss')
  313. ->willReturn('scss {}');
  314. $actual = self::invokePrivate($this->scssCacher, 'cache', [$path, $fileNameCSS, $fileNameSCSS, $folder, $webDir]);
  315. $this->assertTrue($actual);
  316. }
  317. public function testCacheSuccess() {
  318. $fileNameCSS = "styles-success.css";
  319. $fileNameSCSS = "../../tests/data/scss/styles-success.scss";
  320. $folder = $this->createMock(ISimpleFolder::class);
  321. $file = $this->createMock(ISimpleFile::class);
  322. $depsFile = $this->createMock(ISimpleFile::class);
  323. $gzipFile = $this->createMock(ISimpleFile::class);
  324. $webDir = "tests/data/scss";
  325. $path = \OC::$SERVERROOT . $webDir;
  326. $folder->method('getFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) {
  327. if ($fileName === 'styles-success.css') {
  328. return $file;
  329. } elseif ($fileName === 'styles-success.css.deps') {
  330. return $depsFile;
  331. } elseif ($fileName === 'styles-success.css.gzip') {
  332. return $gzipFile;
  333. }
  334. throw new \Exception();
  335. });
  336. $this->iconsCacher->expects($this->at(0))
  337. ->method('setIconsCss')
  338. ->willReturn('body{background-color:#0082c9}');
  339. $file->expects($this->at(0))->method('putContent')->with($this->callback(
  340. function ($content) {
  341. return 'body{background-color:#0082c9}' === $content;
  342. }));
  343. $depsFile->expects($this->at(0))->method('putContent')->with($this->callback(
  344. function ($content) {
  345. $deps = json_decode($content, true);
  346. return array_key_exists(\OC::$SERVERROOT . '/core/css/variables.scss', $deps)
  347. && array_key_exists(\OC::$SERVERROOT . '/tests/data/scss/styles-success.scss', $deps);
  348. }));
  349. $gzipFile->expects($this->at(0))->method('putContent')->with($this->callback(
  350. function ($content) {
  351. return gzdecode($content) === 'body{background-color:#0082c9}';
  352. }
  353. ));
  354. $actual = self::invokePrivate($this->scssCacher, 'cache', [$path, $fileNameCSS, $fileNameSCSS, $folder, $webDir]);
  355. $this->assertTrue($actual);
  356. }
  357. public function testCacheFailure() {
  358. $fileNameCSS = "styles-error.css";
  359. $fileNameSCSS = "../../tests/data/scss/styles-error.scss";
  360. $folder = $this->createMock(ISimpleFolder::class);
  361. $file = $this->createMock(ISimpleFile::class);
  362. $depsFile = $this->createMock(ISimpleFile::class);
  363. $webDir = "/tests/data/scss";
  364. $path = \OC::$SERVERROOT . $webDir;
  365. $folder->expects($this->at(0))->method('getFile')->with($fileNameCSS)->willReturn($file);
  366. $folder->expects($this->at(1))->method('getFile')->with($fileNameCSS . '.deps')->willReturn($depsFile);
  367. $actual = self::invokePrivate($this->scssCacher, 'cache', [$path, $fileNameCSS, $fileNameSCSS, $folder, $webDir]);
  368. $this->assertFalse($actual);
  369. }
  370. public function dataRebaseUrls() {
  371. return [
  372. ['#id { background-image: url(\'../img/image.jpg\'); }','#id { background-image: url(\'/apps/files/css/../img/image.jpg\'); }'],
  373. ['#id { background-image: url("../img/image.jpg"); }','#id { background-image: url(\'/apps/files/css/../img/image.jpg\'); }'],
  374. ['#id { background-image: url(\'/img/image.jpg\'); }','#id { background-image: url(\'/img/image.jpg\'); }'],
  375. ['#id { background-image: url("http://example.com/test.jpg"); }','#id { background-image: url("http://example.com/test.jpg"); }'],
  376. ];
  377. }
  378. /**
  379. * @dataProvider dataRebaseUrls
  380. */
  381. public function testRebaseUrls($scss, $expected) {
  382. $webDir = '/apps/files/css';
  383. $actual = self::invokePrivate($this->scssCacher, 'rebaseUrls', [$scss, $webDir]);
  384. $this->assertEquals($expected, $actual);
  385. }
  386. public function dataGetCachedSCSS() {
  387. return [
  388. ['core', 'core/css/styles.scss', '/css/core/styles.css', \OC_Util::getVersionString()],
  389. ['files', 'apps/files/css/styles.scss', '/css/files/styles.css', \OC_App::getAppVersion('files')]
  390. ];
  391. }
  392. /**
  393. * @param $appName
  394. * @param $fileName
  395. * @param $result
  396. * @dataProvider dataGetCachedSCSS
  397. */
  398. public function testGetCachedSCSS($appName, $fileName, $result, $version) {
  399. $this->urlGenerator->expects($this->once())
  400. ->method('linkToRoute')
  401. ->with('core.Css.getCss', [
  402. 'fileName' => substr(md5($version), 0, 4) . '-' .
  403. substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-styles.css',
  404. 'appName' => $appName,
  405. 'v' => 0,
  406. ])
  407. ->willReturn(\OC::$WEBROOT . $result);
  408. $actual = $this->scssCacher->getCachedSCSS($appName, $fileName);
  409. $this->assertEquals(substr($result, 1), $actual);
  410. }
  411. private function randomString() {
  412. return sha1(uniqid(mt_rand(), true));
  413. }
  414. private function rrmdir($directory) {
  415. $files = array_diff(scandir($directory), ['.','..']);
  416. foreach ($files as $file) {
  417. if (is_dir($directory . '/' . $file)) {
  418. $this->rrmdir($directory . '/' . $file);
  419. } else {
  420. unlink($directory . '/' . $file);
  421. }
  422. }
  423. return rmdir($directory);
  424. }
  425. public function dataGetWebDir() {
  426. return [
  427. // Root installation
  428. ['/http/core/css', 'core', '', '/http', '/core/css'],
  429. ['/http/apps/scss/css', 'scss', '', '/http', '/apps/scss/css'],
  430. ['/srv/apps2/scss/css', 'scss', '', '/http', '/apps2/scss/css'],
  431. // Sub directory install
  432. ['/http/nextcloud/core/css', 'core', '/nextcloud', '/http/nextcloud', '/nextcloud/core/css'],
  433. ['/http/nextcloud/apps/scss/css', 'scss', '/nextcloud', '/http/nextcloud', '/nextcloud/apps/scss/css'],
  434. ['/srv/apps2/scss/css', 'scss', '/nextcloud', '/http/nextcloud', '/apps2/scss/css']
  435. ];
  436. }
  437. /**
  438. * @param $path
  439. * @param $appName
  440. * @param $webRoot
  441. * @param $serverRoot
  442. * @dataProvider dataGetWebDir
  443. */
  444. public function testgetWebDir($path, $appName, $webRoot, $serverRoot, $correctWebDir) {
  445. $tmpDir = sys_get_temp_dir().'/'.$this->randomString();
  446. // Adding fake apps folder and create fake app install
  447. \OC::$APPSROOTS[] = [
  448. 'path' => $tmpDir.'/srv/apps2',
  449. 'url' => '/apps2',
  450. 'writable' => false
  451. ];
  452. mkdir($tmpDir.$path, 0777, true);
  453. $actual = self::invokePrivate($this->scssCacher, 'getWebDir', [$tmpDir.$path, $appName, $tmpDir.$serverRoot, $webRoot]);
  454. $this->assertEquals($correctWebDir, $actual);
  455. array_pop(\OC::$APPSROOTS);
  456. $this->rrmdir($tmpDir.$path);
  457. }
  458. public function testResetCache() {
  459. $file = $this->createMock(ISimpleFile::class);
  460. $file->expects($this->once())
  461. ->method('delete');
  462. $folder = $this->createMock(ISimpleFolder::class);
  463. $folder->expects($this->once())
  464. ->method('getDirectoryListing')
  465. ->willReturn([$file]);
  466. $cache = $this->createMock(ICache::class);
  467. $this->cacheFactory->expects($this->exactly(2))
  468. ->method('createDistributed')
  469. ->willReturn($cache);
  470. $cache->expects($this->exactly(2))
  471. ->method('clear')
  472. ->with('');
  473. $this->appData->expects($this->once())
  474. ->method('getDirectoryListing')
  475. ->willReturn([$folder]);
  476. $this->scssCacher->resetCache();
  477. }
  478. }