aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Template
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-05-10 16:54:58 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-05-10 23:24:07 +0200
commit3c6253f9659d6fb5c059cfb6916654a5c2a7c52e (patch)
tree95fff4b6cd1efcb479912d1852e0b0efaf1af565 /tests/lib/Template
parentc59c3b5c1f8fba38d6b2e4bfd19714cb1f75ba85 (diff)
downloadnextcloud-server-3c6253f9659d6fb5c059cfb6916654a5c2a7c52e.tar.gz
nextcloud-server-3c6253f9659d6fb5c059cfb6916654a5c2a7c52e.zip
Remove old legacy SvgController and IconsCacher
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'tests/lib/Template')
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php5
-rw-r--r--tests/lib/Template/IconsCacherTest.php149
-rw-r--r--tests/lib/Template/SCSSCacherTest.php36
3 files changed, 0 insertions, 190 deletions
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index 4832b03fe9b..8f93ef6d9df 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -27,7 +27,6 @@ use OC\AppConfig;
use OC\Files\AppData\AppData;
use OC\Files\AppData\Factory;
use OC\Template\CSSResourceLocator;
-use OC\Template\IconsCacher;
use OC\Template\SCSSCacher;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -50,8 +49,6 @@ class CSSResourceLocatorTest extends \Test\TestCase {
protected $cacheFactory;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
- /** @var IconsCacher|\PHPUnit\Framework\MockObject\MockObject */
- protected $iconsCacher;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
/** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */
@@ -66,7 +63,6 @@ class CSSResourceLocatorTest extends \Test\TestCase {
$this->config = $this->createMock(IConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
- $this->iconsCacher = $this->createMock(IconsCacher::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->appConfig = $this->createMock(AppConfig::class);
}
@@ -83,7 +79,6 @@ class CSSResourceLocatorTest extends \Test\TestCase {
$this->themingDefaults,
\OC::$SERVERROOT,
$this->cacheFactory,
- $this->iconsCacher,
$this->timeFactory,
$this->appConfig
);
diff --git a/tests/lib/Template/IconsCacherTest.php b/tests/lib/Template/IconsCacherTest.php
deleted file mode 100644
index 188c0596799..00000000000
--- a/tests/lib/Template/IconsCacherTest.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-declare(strict_types = 1);
-/**
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
- *
- * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Test\Template;
-
-use OC\Files\AppData\AppData;
-use OC\Files\AppData\Factory;
-use OC\Template\IconsCacher;
-use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\Files\IAppData;
-use OCP\Files\SimpleFS\ISimpleFile;
-use OCP\Files\SimpleFS\ISimpleFolder;
-use OCP\IURLGenerator;
-use Psr\Log\LoggerInterface;
-
-class IconsCacherTest extends \Test\TestCase {
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
- protected $logger;
- /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
- protected $appData;
- /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
- protected $urlGenerator;
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
-
- protected function setUp(): void {
- $this->logger = $this->createMock(LoggerInterface::class);
- $this->appData = $this->createMock(AppData::class);
- $this->timeFactory = $this->createMock(ITimeFactory::class);
-
- /** @var Factory|\PHPUnit\Framework\MockObject\MockObject $factory */
- $factory = $this->createMock(Factory::class);
- $factory->method('get')->with('css')->willReturn($this->appData);
-
- $this->folder = $this->createMock(ISimpleFolder::class);
- $this->appData->method('getFolder')->willReturn($this->folder);
-
- $this->urlGenerator = $this->createMock(IURLGenerator::class);
-
- $this->iconsCacher = new IconsCacher(
- $this->logger,
- $factory,
- $this->urlGenerator,
- $this->timeFactory
- );
- }
-
- public function testGetIconsFromEmptyCss() {
- $css = "
- icon.test {
- color: #aaa;
- }
- ";
- $icons = self::invokePrivate($this->iconsCacher, 'getIconsFromCss', [$css]);
- $this->assertTrue(empty($icons));
- }
-
- public function testGetIconsFromValidCss() {
- $css = "
- icon.test {
- --icon-test: url('/svg/core/actions/add/000?v=1');
- background-image: var(--icon-test);
- }
- ";
- $actual = self::invokePrivate($this->iconsCacher, 'getIconsFromCss', [$css]);
- $expected = [
- 'icon-test' => '/svg/core/actions/add/000?v=1'
- ];
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetIconsFromEmptyCss() {
- $expected = "
- icon.test {
- color: #aaa;
- }
- ";
- $actual = $this->iconsCacher->setIconsCss($expected);
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetIconsFromValidCss() {
- $css = "
- icon.test {
- --icon-test: url('/index.php/svg/core/actions/add?color=000&v=1');
- background-image: var(--icon-test);
- }
- ";
- $expected = "
- icon.test {
- \n background-image: var(--icon-test);
- }
- ";
-
- $iconsFile = $this->createMock(ISimpleFile::class);
- $this->folder->expects($this->exactly(2))
- ->method('getFile')
- ->willReturn($iconsFile);
-
- $actual = $this->iconsCacher->setIconsCss($css);
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetIconsFromValidCssMultipleTimes() {
- $css = "
- icon.test {
- --icon-test: url('/index.php/svg/core/actions/add?color=000&v=1');
- background-image: var(--icon-test);
- }
- ";
- $expected = "
- icon.test {
- \n background-image: var(--icon-test);
- }
- ";
-
- $iconsFile = $this->createMock(ISimpleFile::class);
- $this->folder->expects($this->exactly(4))
- ->method('getFile')
- ->willReturn($iconsFile);
-
- $actual = $this->iconsCacher->setIconsCss($css);
- $actual = $this->iconsCacher->setIconsCss($actual);
- $actual = $this->iconsCacher->setIconsCss($actual);
- $this->assertEquals($expected, $actual);
- }
-}
diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php
index f7b7b3bb6d3..576ba35d009 100644
--- a/tests/lib/Template/SCSSCacherTest.php
+++ b/tests/lib/Template/SCSSCacherTest.php
@@ -26,7 +26,6 @@ namespace Test\Template;
use OC\AppConfig;
use OC\Files\AppData\AppData;
use OC\Files\AppData\Factory;
-use OC\Template\IconsCacher;
use OC\Template\SCSSCacher;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -59,8 +58,6 @@ class SCSSCacherTest extends \Test\TestCase {
protected $isCachedCache;
/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
protected $cacheFactory;
- /** @var IconsCacher|\PHPUnit\Framework\MockObject\MockObject */
- protected $iconsCacher;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
protected $timeFactory;
/** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */
@@ -70,7 +67,6 @@ class SCSSCacherTest extends \Test\TestCase {
parent::setUp();
$this->logger = $this->createMock(LoggerInterface::class);
$this->appData = $this->createMock(AppData::class);
- $this->iconsCacher = $this->createMock(IconsCacher::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
/** @var Factory|\PHPUnit\Framework\MockObject\MockObject $factory */
@@ -104,9 +100,6 @@ class SCSSCacherTest extends \Test\TestCase {
$this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]);
$iconsFile = $this->createMock(ISimpleFile::class);
- $this->iconsCacher->expects($this->any())
- ->method('getCachedCSS')
- ->willReturn($iconsFile);
$this->appConfig = $this->createMock(AppConfig::class);
@@ -118,7 +111,6 @@ class SCSSCacherTest extends \Test\TestCase {
$this->themingDefaults,
\OC::$SERVERROOT,
$this->cacheFactory,
- $this->iconsCacher,
$this->timeFactory,
$this->appConfig
);
@@ -159,10 +151,6 @@ class SCSSCacherTest extends \Test\TestCase {
->method('getBaseUrl')
->willReturn('http://localhost/nextcloud');
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
$this->assertTrue($actual);
}
@@ -195,10 +183,6 @@ class SCSSCacherTest extends \Test\TestCase {
->with($filePrefix.'styles.css.deps')
->willReturn($fileDeps);
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
$this->assertTrue($actual);
}
@@ -226,10 +210,6 @@ class SCSSCacherTest extends \Test\TestCase {
$this->fail();
});
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
$this->assertTrue($actual);
}
@@ -264,10 +244,6 @@ class SCSSCacherTest extends \Test\TestCase {
$this->fail();
});
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
$this->assertTrue($actual);
}
@@ -330,10 +306,6 @@ class SCSSCacherTest extends \Test\TestCase {
throw new \Exception();
});
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$file->expects($this->once())->method('putContent');
$depsFile->expects($this->once())->method('putContent');
$gzipFile->expects($this->once())->method('putContent');
@@ -368,10 +340,6 @@ class SCSSCacherTest extends \Test\TestCase {
$depsFile->expects($this->once())->method('putContent');
$gzipFile->expects($this->once())->method('putContent');
- $this->iconsCacher->expects($this->any())
- ->method('setIconsCss')
- ->willReturn('scss {}');
-
$actual = self::invokePrivate($this->scssCacher, 'cache', [$path, $fileNameCSS, $fileNameSCSS, $folder, $webDir]);
$this->assertTrue($actual);
}
@@ -398,10 +366,6 @@ class SCSSCacherTest extends \Test\TestCase {
throw new \Exception();
});
- $this->iconsCacher->expects($this->at(0))
- ->method('setIconsCss')
- ->willReturn('body{background-color:#0082c9}');
-
$file->expects($this->at(0))->method('putContent')->with($this->callback(
function ($content) {
return 'body{background-color:#0082c9}' === $content;