]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed tests
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Thu, 28 Dec 2017 13:19:13 +0000 (14:19 +0100)
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Wed, 3 Jan 2018 21:05:03 +0000 (22:05 +0100)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
lib/private/Template/SCSSCacher.php
tests/lib/LegacyHelperTest.php
tests/lib/Template/SCSSCacherTest.php
tests/lib/UrlGeneratorTest.php

index 5b904bced65ef98a9552ed45b6309a1c87382f82..542ca1688f556b66332a242a70be85d453e16a25 100644 (file)
@@ -319,7 +319,7 @@ class SCSSCacher {
         */
        private function getWebDir($path, $appName, $serverRoot, $webRoot) {
                // Detect if path is within server root AND if path is within an app path
-               if ( !strpos($path, $serverRoot) && $appWebPath = \OC_App::getAppWebPath($appName) ) {
+               if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
                        // Get the file path within the app directory
                        $appDirectoryPath = explode($appName, $path)[1];
                        // Remove the webroot
index f1e22ea600ecbca65c5fa3cd5f7b7f660829b753..736c5bf7fad78185be8aafd725c4af643c8703b7 100644 (file)
@@ -12,6 +12,17 @@ use OC\Files\View;
 use OC_Helper;
 
 class LegacyHelperTest extends \Test\TestCase {
+       /** @var string */
+       private $originalWebRoot;
+
+       public function setUp() {
+               $this->originalWebRoot = \OC::$WEBROOT;
+       }
+
+       public function tearDown() {
+               // Reset webRoot
+               \OC::$WEBROOT = $this->originalWebRoot;
+       }
 
        /**
         * @dataProvider humanFileSizeProvider
index 712c00262d68cfc1cc767b80e092c33f65a20ff4..1c915fd690ca1417696d68f76778209a241f8e1e 100644 (file)
@@ -384,17 +384,6 @@ class SCSSCacherTest extends \Test\TestCase {
                $this->assertEquals(substr($result, 1), $actual);
        }
 
-       public function dataGetWebDir() {
-               return [
-                       ['/http/core/css', 'core', '', '/http', '/core/css'],
-                       ['/http/apps/test/css', 'test', '', '/http', '/apps/test/css'],
-                       ['/http/nextcloud/core/css', 'core', '/nextcloud', '/http/nextcloud', '/nextcloud/core/css'],
-                       ['/http/nextcloud/apps/test/css', 'test', '/nextcloud', '/http/nextcloud', '/nextcloud/apps/test/css'],
-                       ['/srv/apps2/test/css', 'test', '', '/http', '/apps2/test/css'],
-                       ['/srv/apps2/test/css', 'test', '/nextcloud', '/http/nextcloud', '/apps2/test/css']
-               ];
-       }
-
        private function randomString() {
                return sha1(uniqid(mt_rand(), true));
        }
@@ -411,6 +400,19 @@ class SCSSCacherTest extends \Test\TestCase {
                return rmdir($directory);
        }
 
+       public function dataGetWebDir() {
+               return [
+                       // Root installation
+                       ['/http/core/css',              'core', '', '/http', '/core/css'],
+                       ['/http/apps/scss/css', 'scss', '', '/http', '/apps/scss/css'],
+                       ['/srv/apps2/scss/css', 'scss', '', '/http', '/apps2/scss/css'],
+                       // Sub directory install
+                       ['/http/nextcloud/core/css',      'core',       '/nextcloud', '/http/nextcloud', '/nextcloud/core/css'],
+                       ['/http/nextcloud/apps/scss/css', 'scss',       '/nextcloud', '/http/nextcloud', '/nextcloud/apps/scss/css'],
+                       ['/srv/apps2/scss/css',                   'scss',       '/nextcloud', '/http/nextcloud', '/apps2/scss/css']
+               ];
+       }
+
        /**
         * @param $path
         * @param $appName
index 69067f51e081c26dcde790cf42d3a399ffe63ccf..340c9c7082d219404affbbf5020319b9b963968a 100644 (file)
@@ -27,6 +27,8 @@ class UrlGeneratorTest extends \Test\TestCase {
        private $request;
        /** @var IURLGenerator */
        private $urlGenerator;
+       /** @var string */
+       private $originalWebRoot;
 
        public function setUp() {
                parent::setUp();
@@ -38,6 +40,12 @@ class UrlGeneratorTest extends \Test\TestCase {
                        $this->cacheFactory,
                        $this->request
                );
+               $this->originalWebRoot = \OC::$WEBROOT;
+       }
+
+       public function tearDown() {
+               // Reset webRoot
+               \OC::$WEBROOT = $this->originalWebRoot;
        }
 
        private function mockBaseUrl() {
@@ -47,7 +55,6 @@ class UrlGeneratorTest extends \Test\TestCase {
                $this->request->expects($this->once())
                        ->method('getServerHost')
                        ->willReturn('localhost');
-
        }
 
        /**
@@ -156,4 +163,3 @@ class UrlGeneratorTest extends \Test\TestCase {
        }
 
 }
-