From fb6c5cc41618a476fc2ac47fb0f4fd137029ec62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 27 Dec 2017 11:00:46 +0100 Subject: [PATCH 1/8] Fixed scss url rewriting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 8f6cb85a12..d7e2441f41 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -103,7 +103,17 @@ class SCSSCacher { $path = implode('/', $path); - $webDir = substr($path, strlen($this->serverRoot)+1); + // Detect if path is within an app path + $app_paths = $this->config->getSystemValue('apps_paths'); + foreach ($app_paths as $app_path) { + if(strpos($path, $app_path["path"]) === 0) { + $webDir = $app_path["url"].str_replace($app_path["path"], '', $path); + break; + } + } + if(is_null($webDir)) { + $webDir = substr($path, strlen($this->serverRoot)); + } try { $folder = $this->appData->getFolder($app); @@ -155,7 +165,7 @@ class SCSSCacher { } } } - return true; + return false; } catch(NotFoundException $e) { return false; } @@ -283,12 +293,7 @@ class SCSSCacher { */ private function rebaseUrls($css, $webDir) { $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; - // OC\Route\Router:75 - if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { - $subst = 'url(\'../../'.$webDir.'/$1\')'; - } else { - $subst = 'url(\'../../../'.$webDir.'/$1\')'; - } + $subst = 'url(\''.$webDir.'/$1\')'; return preg_replace($re, $subst, $css); } @@ -299,6 +304,7 @@ class SCSSCacher { * @return string */ public function getCachedSCSS($appName, $fileName) { + //var_dump([$appName, $fileName]); $tmpfileLoc = explode('/', $fileName); $fileName = array_pop($tmpfileLoc); $fileName = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)); From 89ca9cb35cb62d603370e6424c83886da00342aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 27 Dec 2017 11:01:27 +0100 Subject: [PATCH 2/8] Fixed webroot for scss files Fixed tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/CSSResourceLocator.php | 4 ++-- lib/private/Template/SCSSCacher.php | 16 +++++++++------- tests/lib/Template/SCSSCacherTest.php | 13 ++----------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 3c30a9d335..5ca05d1b95 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -108,7 +108,7 @@ class CSSResourceLocator extends ResourceLocator { if($this->scssCacher !== null) { if($this->scssCacher->process($root, $file, $app)) { - $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), false, true, true); + $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true); return true; } else { $this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); @@ -145,7 +145,7 @@ class CSSResourceLocator extends ResourceLocator { } } - $this->resources[] = array($webRoot? : '/', $webRoot, $file); + $this->resources[] = array($webRoot? : \OC::$WEBROOT, $webRoot, $file); } } } diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index d7e2441f41..eb3636a189 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,16 +102,19 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); + $webDir = null; // Detect if path is within an app path $app_paths = $this->config->getSystemValue('apps_paths'); - foreach ($app_paths as $app_path) { - if(strpos($path, $app_path["path"]) === 0) { - $webDir = $app_path["url"].str_replace($app_path["path"], '', $path); - break; + if (!empty($app_paths)) { + foreach ($app_paths as $app_path) { + if (strpos($path, $app_path["path"]) === 0) { + $webDir = $app_path["url"].str_replace($app_path["path"], '', $path); + break; + } } } - if(is_null($webDir)) { + if (is_null($webDir)) { $webDir = substr($path, strlen($this->serverRoot)); } @@ -165,7 +168,7 @@ class SCSSCacher { } } } - return false; + return true; } catch(NotFoundException $e) { return false; } @@ -304,7 +307,6 @@ class SCSSCacher { * @return string */ public function getCachedSCSS($appName, $fileName) { - //var_dump([$appName, $fileName]); $tmpfileLoc = explode('/', $fileName); $fileName = array_pop($tmpfileLoc); $fileName = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)); diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 3825bc44c5..27d427aa34 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -352,19 +352,10 @@ class SCSSCacherTest extends \Test\TestCase { } public function testRebaseUrls() { - $webDir = 'apps/files/css'; + $webDir = '/apps/files/css'; $css = '#id { background-image: url(\'../img/image.jpg\'); }'; $actual = self::invokePrivate($this->scssCacher, 'rebaseUrls', [$css, $webDir]); - $expected = '#id { background-image: url(\'../../../apps/files/css/../img/image.jpg\'); }'; - $this->assertEquals($expected, $actual); - } - - public function testRebaseUrlsIgnoreFrontendController() { - $this->config->expects($this->once())->method('getSystemValue')->with('htaccess.IgnoreFrontController', false)->willReturn(true); - $webDir = 'apps/files/css'; - $css = '#id { background-image: url(\'../img/image.jpg\'); }'; - $actual = self::invokePrivate($this->scssCacher, 'rebaseUrls', [$css, $webDir]); - $expected = '#id { background-image: url(\'../../apps/files/css/../img/image.jpg\'); }'; + $expected = '#id { background-image: url(\'/apps/files/css/../img/image.jpg\'); }'; $this->assertEquals($expected, $actual); } From ad20af619fa3d71d806c12fb10b418ace9cf0f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 27 Dec 2017 16:44:14 +0100 Subject: [PATCH 3/8] getWebDir function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index eb3636a189..300187cf74 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,21 +102,7 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); - $webDir = null; - - // Detect if path is within an app path - $app_paths = $this->config->getSystemValue('apps_paths'); - if (!empty($app_paths)) { - foreach ($app_paths as $app_path) { - if (strpos($path, $app_path["path"]) === 0) { - $webDir = $app_path["url"].str_replace($app_path["path"], '', $path); - break; - } - } - } - if (is_null($webDir)) { - $webDir = substr($path, strlen($this->serverRoot)); - } + $webDir = $this->getWebDir($path); try { $folder = $this->appData->getFolder($app); @@ -323,4 +309,22 @@ class SCSSCacher { $frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 8) . '-' . $cssFile; } + + /** + * Prepend hashed base url to the css file + * @param string $path the css file path + * @return string the webDir + */ + private function getWebDir($path) { + // Detect if path is within an app path + $app_paths = $this->config->getSystemValue('apps_paths'); + if (!empty($app_paths)) { + foreach ($app_paths as $app_path) { + if (strpos($path, $app_path["path"]) === 0) { + return $app_path["url"].str_replace($app_path["path"], '', $path); + } + } + } + return substr($path, strlen($this->serverRoot)); + } } From dc938628f7bacd16f88b2cf9cff3f46ec03fc929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 28 Dec 2017 10:25:10 +0100 Subject: [PATCH 4/8] Use OC_Util function for app web path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 300187cf74..0409071102 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,7 +102,7 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); - $webDir = $this->getWebDir($path); + $webDir = $this->getWebDir($path, $app); try { $folder = $this->appData->getFolder($app); @@ -311,20 +311,23 @@ class SCSSCacher { } /** - * Prepend hashed base url to the css file + * Get WebDir root * @param string $path the css file path + * @param string $app the app name * @return string the webDir */ - private function getWebDir($path) { - // Detect if path is within an app path - $app_paths = $this->config->getSystemValue('apps_paths'); - if (!empty($app_paths)) { - foreach ($app_paths as $app_path) { - if (strpos($path, $app_path["path"]) === 0) { - return $app_path["url"].str_replace($app_path["path"], '', $path); - } - } + private function getWebDir($path, $app) { + // Detect if path is within server root + if(strpos($path, $this->serverRoot) > -1) { + return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); } - return substr($path, strlen($this->serverRoot)); + // Detect if path is within an app path + if($appWebPath = \OC_App::getAppWebPath($app)) { + // Get the file path within the app directory + $appDirectoryPath = explode($app, $path)[1]; + // Remove the webroot + return str_replace(\OC::$WEBROOT, '', $appWebPath.$appDirectoryPath); + } + return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); } } From 88b72fd027e50c4f45d2a5eb47762dae67815593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 28 Dec 2017 10:28:16 +0100 Subject: [PATCH 5/8] Fixup! getWebdir return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 0409071102..8d1eda99ee 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -317,12 +317,8 @@ class SCSSCacher { * @return string the webDir */ private function getWebDir($path, $app) { - // Detect if path is within server root - if(strpos($path, $this->serverRoot) > -1) { - return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); - } - // Detect if path is within an app path - if($appWebPath = \OC_App::getAppWebPath($app)) { + // Detect if path is within server root AND if path is within an app path + if ( strpos($path, $this->serverRoot) === -1 && $appWebPath = \OC_App::getAppWebPath($app) ) { // Get the file path within the app directory $appDirectoryPath = explode($app, $path)[1]; // Remove the webroot From 02bfc867efd992c6b5b17bcdc76316cb1c970853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 28 Dec 2017 13:32:45 +0100 Subject: [PATCH 6/8] Added tests for various installations types - With root installation - Core css - App inside server root - Secondary apps directory outside server root - With an installation in a sub directory - Core css - App inside server root - Secondary apps directory outside server root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 18 +++++++------ tests/lib/Template/SCSSCacherTest.php | 37 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 8d1eda99ee..ddd0131eac 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,7 +102,7 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); - $webDir = $this->getWebDir($path, $app); + $webDir = $this->getWebDir($path, $app, $this->serverRoot, \OC::$WEBROOT); try { $folder = $this->appData->getFolder($app); @@ -187,7 +187,7 @@ class SCSSCacher { $scss = new Compiler(); $scss->setImportPaths([ $path, - \OC::$SERVERROOT . '/core/css/', + $this->serverRoot . '/core/css/', ]); // Continue after throw $scss->setIgnoreErrors(true); @@ -313,17 +313,19 @@ class SCSSCacher { /** * Get WebDir root * @param string $path the css file path - * @param string $app the app name + * @param string $appName the app name + * @param string $serverRoot the server root path + * @param string $webRoot the nextcloud installation root path * @return string the webDir */ - private function getWebDir($path, $app) { + 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, $this->serverRoot) === -1 && $appWebPath = \OC_App::getAppWebPath($app) ) { + if ( !strpos($path, $serverRoot) && $appWebPath = \OC_App::getAppWebPath($appName) ) { // Get the file path within the app directory - $appDirectoryPath = explode($app, $path)[1]; + $appDirectoryPath = explode($appName, $path)[1]; // Remove the webroot - return str_replace(\OC::$WEBROOT, '', $appWebPath.$appDirectoryPath); + return str_replace($webRoot, '', $appWebPath.$appDirectoryPath); } - return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); + return $webRoot.substr($path, strlen($serverRoot)); } } diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 27d427aa34..6ecfc0e7aa 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -384,4 +384,41 @@ 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)); + } + + /** + * @param $path + * @param $appName + * @param $webRoot + * @param $serverRoot + * @dataProvider dataGetWebDir + */ + public function testgetWebDir($path, $appName, $webRoot, $serverRoot, $correctWebDir) { + $tmpDir = sys_get_temp_dir().'/'.$this->randomString(); + // Adding fake apps folder and create fake app install + \OC::$APPSROOTS[] = [ + 'path' => $tmpDir.'/srv/apps2', + 'url' => '/apps2', + 'writable' => false + ]; + mkdir($tmpDir.$path, 0777, true); + $actual = self::invokePrivate($this->scssCacher, 'getWebDir', [$tmpDir.$path, $appName, $tmpDir.$serverRoot, $webRoot]); + $this->assertEquals($correctWebDir, $actual); + array_pop(\OC::$APPSROOTS); + rmdir($tmpDir.$path); + } + } From b71c9205ef784b7aa55f5f51207f9ba49e077a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 28 Dec 2017 13:41:38 +0100 Subject: [PATCH 7/8] Correctly remove temp test directory tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- tests/lib/Template/SCSSCacherTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 6ecfc0e7aa..7a1c582925 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -399,6 +399,18 @@ class SCSSCacherTest extends \Test\TestCase { return sha1(uniqid(mt_rand(), true)); } + private function rrmdir($directory) { + $files = array_diff(scandir($directory), array('.','..')); + foreach ($files as $file) { + if (is_dir($directory . '/' . $file)) { + $this->rrmdir($directory . '/' . $file); + } else { + unlink($directory . '/' . $file); + } + } + return rmdir($directory); + } + /** * @param $path * @param $appName @@ -418,7 +430,7 @@ class SCSSCacherTest extends \Test\TestCase { $actual = self::invokePrivate($this->scssCacher, 'getWebDir', [$tmpDir.$path, $appName, $tmpDir.$serverRoot, $webRoot]); $this->assertEquals($correctWebDir, $actual); array_pop(\OC::$APPSROOTS); - rmdir($tmpDir.$path); + $this->rrmdir($tmpDir.$path); } } From c0c4443ffc6608ea2917a9c5bec1c0150a94b404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 28 Dec 2017 14:19:13 +0100 Subject: [PATCH 8/8] Fixed tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 2 +- tests/lib/LegacyHelperTest.php | 11 +++++++++++ tests/lib/Template/SCSSCacherTest.php | 24 +++++++++++++----------- tests/lib/UrlGeneratorTest.php | 10 ++++++++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index ddd0131eac..a460442554 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -320,7 +320,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 diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php index f1e22ea600..736c5bf7fa 100644 --- a/tests/lib/LegacyHelperTest.php +++ b/tests/lib/LegacyHelperTest.php @@ -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 diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 7a1c582925..fca9500810 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -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 diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index 69067f51e0..340c9c7082 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/tests/lib/UrlGeneratorTest.php @@ -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 { } } -