]> source.dussan.org Git - nextcloud-server.git/commitdiff
Drop 3rdparty root since it is unused and adjust tests 35223/head
authorJulius Härtl <jus@bitgrid.net>
Wed, 7 Dec 2022 22:16:06 +0000 (23:16 +0100)
committerJulius Härtl <jus@bitgrid.net>
Wed, 7 Dec 2022 22:55:32 +0000 (23:55 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/Template/CSSResourceLocator.php
lib/private/Template/JSResourceLocator.php
lib/private/Template/ResourceLocator.php
tests/lib/Template/JSResourceLocatorTest.php
tests/lib/Template/ResourceLocatorTest.php

index beb5178476b9978d7f1159bc816d95180f76c4d6..5047b3e906f82d857c7fff5720b7672868833718 100644 (file)
@@ -44,8 +44,7 @@ class CSSResourceLocator extends ResourceLocator {
        public function doFind($style) {
                $app = substr($style, 0, strpos($style, '/'));
                if (strpos($style, '3rdparty') === 0
-                       && $this->appendIfExist($this->thirdpartyroot, $style.'.css')
-                       || $this->appendIfExist($this->serverroot, $style.'.css')
+                       && $this->appendIfExist($this->serverroot, $style.'.css')
                        || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
                ) {
                        return;
index 00cfde1f9f5e57a98f7d6b6da58fea4e662a285c..88323af75dedcbc0fc9c2219ddc57e754ec1897b 100644 (file)
@@ -45,10 +45,6 @@ class JSResourceLocator extends ResourceLocator {
         */
        public function doFind($script) {
                $theme_dir = 'themes/'.$this->theme.'/';
-               if (strpos($script, '3rdparty') === 0
-                       && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) {
-                       return;
-               }
 
                // Extracting the appId and the script file name
                $app = substr($script, 0, strpos($script, '/'));
index dec74ed1ab83f9253823e24b18ece17dd88f8815..9e6e2056e6b329d78c3c44a650c4ec672fe0ad4d 100755 (executable)
@@ -36,7 +36,6 @@ abstract class ResourceLocator {
 
        protected $mapping;
        protected $serverroot;
-       protected $thirdpartyroot;
        protected $webroot;
 
        protected $resources = [];
@@ -49,8 +48,7 @@ abstract class ResourceLocator {
                        \OC::$SERVERROOT => \OC::$WEBROOT
                ];
                $this->serverroot = \OC::$SERVERROOT;
-               $this->thirdpartyroot = \OC::$SERVERROOT;
-               $this->webroot = $this->mapping[$this->serverroot];
+               $this->webroot = \OC::$WEBROOT;
                $this->theme = \OC_Util::getTheme();
        }
 
index 7dedd4ad3c731dbd5d8944c8c7556ef13cd18732..20fd79a91b5af1d6df6754cfe9834f63e442d62e 100644 (file)
@@ -63,9 +63,6 @@ class JSResourceLocatorTest extends \Test\TestCase {
                );
                return new JSResourceLocator(
                        $this->logger,
-                       'theme',
-                       ['core' => 'map'],
-                       ['3rd' => 'party'],
                        $jsCombiner
                );
        }
index 0cb28843a536ae71cf429f4f6112f4f3c9cff5de..fa329ca6581e4ae7879dc2b78601192ea1525d36 100644 (file)
@@ -8,6 +8,7 @@
 
 namespace Test\Template;
 
+use OC\SystemConfig;
 use OC\Template\ResourceNotFoundException;
 use Psr\Log\LoggerInterface;
 
@@ -22,20 +23,23 @@ class ResourceLocatorTest extends \Test\TestCase {
 
        /**
         * @param string $theme
-        * @param array $core_map
-        * @param array $party_map
-        * @param array $appsRoots
         * @return \PHPUnit\Framework\MockObject\MockObject
         */
-       public function getResourceLocator($theme, $core_map, $party_map, $appsRoots) {
+       public function getResourceLocator($theme) {
+               $systemConfig = $this->createMock(SystemConfig::class);
+               $systemConfig
+                       ->expects($this->any())
+                       ->method('getValue')
+                       ->with('theme', '')
+                       ->willReturn($theme);
+               $this->overwriteService(SystemConfig::class, $systemConfig);
                return $this->getMockForAbstractClass('OC\Template\ResourceLocator',
-                       [$this->logger, $theme, $core_map, $party_map, $appsRoots ],
+                       [$this->logger],
                        '', true, true, true, []);
        }
 
        public function testFind() {
-               $locator = $this->getResourceLocator('theme',
-                       ['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
+               $locator = $this->getResourceLocator('theme');
                $locator->expects($this->once())
                        ->method('doFind')
                        ->with('foo');
@@ -47,6 +51,11 @@ class ResourceLocatorTest extends \Test\TestCase {
        }
 
        public function testFindNotFound() {
+               $systemConfig = $this->createMock(SystemConfig::class);
+               $systemConfig->method('getValue')
+                       ->with('theme', '')
+                       ->willReturn('theme');
+               $this->overwriteService(SystemConfig::class, $systemConfig);
                $locator = $this->getResourceLocator('theme',
                        ['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
                $locator->expects($this->once())
@@ -65,8 +74,7 @@ class ResourceLocatorTest extends \Test\TestCase {
        }
 
        public function testAppendIfExist() {
-               $locator = $this->getResourceLocator('theme',
-                       [__DIR__ => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);
+               $locator = $this->getResourceLocator('theme');
                /** @var \OC\Template\ResourceLocator $locator */
                $method = new \ReflectionMethod($locator, 'appendIfExist');
                $method->setAccessible(true);
@@ -75,11 +83,7 @@ class ResourceLocatorTest extends \Test\TestCase {
                $resource1 = [__DIR__, 'webroot', basename(__FILE__)];
                $this->assertEquals([$resource1], $locator->getResources());
 
-               $method->invoke($locator, __DIR__, basename(__FILE__));
-               $resource2 = [__DIR__, 'map', basename(__FILE__)];
-               $this->assertEquals([$resource1, $resource2], $locator->getResources());
-
                $method->invoke($locator, __DIR__, 'does-not-exist');
-               $this->assertEquals([$resource1, $resource2], $locator->getResources());
+               $this->assertEquals([$resource1], $locator->getResources());
        }
 }