summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/comments/js/commentstabview.js2
-rw-r--r--apps/comments/tests/js/commentstabviewSpec.js4
-rw-r--r--apps/dav/appinfo/info.xml5
-rw-r--r--apps/dav/composer/composer/autoload_classmap.php1
-rw-r--r--apps/dav/composer/composer/autoload_static.php1
-rw-r--r--apps/dav/lib/CardDAV/SyncJob.php42
-rw-r--r--apps/files/js/filelist.js3
-rw-r--r--apps/files/tests/js/filelistSpec.js24
-rw-r--r--core/Controller/LoginController.php1
-rw-r--r--core/templates/login.php2
-rw-r--r--lib/private/Template/CSSResourceLocator.php4
-rw-r--r--lib/private/Template/SCSSCacher.php31
-rw-r--r--settings/Activity/SecurityProvider.php2
-rw-r--r--settings/js/apps.js12
-rw-r--r--tests/Core/Controller/LoginControllerTest.php33
-rw-r--r--tests/Settings/Activity/SecurityProviderTest.php4
-rw-r--r--tests/lib/LegacyHelperTest.php11
-rw-r--r--tests/lib/Template/SCSSCacherTest.php64
-rw-r--r--tests/lib/UrlGeneratorTest.php10
19 files changed, 172 insertions, 84 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index 9b75cb4671e..bd89c8bbb49 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -512,7 +512,7 @@
_onTypeComment: function(ev) {
var $field = $(ev.target);
- var len = $field.val().length;
+ var len = $field.text().length;
var $submitButton = $field.data('submitButtonEl');
if (!$submitButton) {
$submitButton = $field.closest('form').find('.submit');
diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js
index 813b2a72eae..0131bc7bce3 100644
--- a/apps/comments/tests/js/commentstabviewSpec.js
+++ b/apps/comments/tests/js/commentstabviewSpec.js
@@ -411,7 +411,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
expect($message.hasClass('error')).toEqual(false);
});
it('displays tooltip when limit is almost reached', function() {
- $message.val(createMessageWithLength(view._commentMaxLength - 2));
+ $message.text(createMessageWithLength(view._commentMaxLength - 2));
$message.trigger('change');
expect(tooltipStub.calledWith('show')).toEqual(true);
@@ -419,7 +419,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
expect($message.hasClass('error')).toEqual(false);
});
it('displays tooltip and disabled button when limit is exceeded', function() {
- $message.val(createMessageWithLength(view._commentMaxLength + 2));
+ $message.text(createMessageWithLength(view._commentMaxLength + 2));
$message.trigger('change');
expect(tooltipStub.calledWith('show')).toEqual(true);
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index 0f97289ba37..25a0d542e85 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -5,7 +5,7 @@
<description>WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
- <version>1.4.5</version>
+ <version>1.4.6</version>
<default_enable/>
<types>
<filesystem/>
@@ -17,9 +17,6 @@
<dependencies>
<nextcloud min-version="13" max-version="13" />
</dependencies>
- <background-jobs>
- <job>OCA\DAV\CardDAV\SyncJob</job>
- </background-jobs>
<repair-steps>
<post-migration>
<step>OCA\DAV\Migration\FixBirthdayCalendarComponent</step>
diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php
index ddb8d7ca8d2..4d2db8e2f5e 100644
--- a/apps/dav/composer/composer/autoload_classmap.php
+++ b/apps/dav/composer/composer/autoload_classmap.php
@@ -59,7 +59,6 @@ return array(
'OCA\\DAV\\CardDAV\\ImageExportPlugin' => $baseDir . '/../lib/CardDAV/ImageExportPlugin.php',
'OCA\\DAV\\CardDAV\\PhotoCache' => $baseDir . '/../lib/CardDAV/PhotoCache.php',
'OCA\\DAV\\CardDAV\\Plugin' => $baseDir . '/../lib/CardDAV/Plugin.php',
- 'OCA\\DAV\\CardDAV\\SyncJob' => $baseDir . '/../lib/CardDAV/SyncJob.php',
'OCA\\DAV\\CardDAV\\SyncService' => $baseDir . '/../lib/CardDAV/SyncService.php',
'OCA\\DAV\\CardDAV\\UserAddressBooks' => $baseDir . '/../lib/CardDAV/UserAddressBooks.php',
'OCA\\DAV\\CardDAV\\Xml\\Groups' => $baseDir . '/../lib/CardDAV/Xml/Groups.php',
diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php
index 46707a93912..42f2e6da286 100644
--- a/apps/dav/composer/composer/autoload_static.php
+++ b/apps/dav/composer/composer/autoload_static.php
@@ -74,7 +74,6 @@ class ComposerStaticInitDAV
'OCA\\DAV\\CardDAV\\ImageExportPlugin' => __DIR__ . '/..' . '/../lib/CardDAV/ImageExportPlugin.php',
'OCA\\DAV\\CardDAV\\PhotoCache' => __DIR__ . '/..' . '/../lib/CardDAV/PhotoCache.php',
'OCA\\DAV\\CardDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CardDAV/Plugin.php',
- 'OCA\\DAV\\CardDAV\\SyncJob' => __DIR__ . '/..' . '/../lib/CardDAV/SyncJob.php',
'OCA\\DAV\\CardDAV\\SyncService' => __DIR__ . '/..' . '/../lib/CardDAV/SyncService.php',
'OCA\\DAV\\CardDAV\\UserAddressBooks' => __DIR__ . '/..' . '/../lib/CardDAV/UserAddressBooks.php',
'OCA\\DAV\\CardDAV\\Xml\\Groups' => __DIR__ . '/..' . '/../lib/CardDAV/Xml/Groups.php',
diff --git a/apps/dav/lib/CardDAV/SyncJob.php b/apps/dav/lib/CardDAV/SyncJob.php
deleted file mode 100644
index f0f8d51c2ca..00000000000
--- a/apps/dav/lib/CardDAV/SyncJob.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\DAV\CardDAV;
-
-use OC\BackgroundJob\TimedJob;
-use OCA\DAV\AppInfo\Application;
-
-class SyncJob extends TimedJob {
-
- public function __construct() {
- // Run once a day
- $this->setInterval(24 * 60 * 60);
- }
-
- protected function run($argument) {
- $app = new Application();
- /** @var SyncService $ss */
- $ss = $app->getSyncService();
- $ss->syncInstance();
- }
-}
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 61e9432dce3..d0c0fc1a7fc 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -683,11 +683,14 @@
// the details to be shown.
event.preventDefault();
var filename = $tr.attr('data-file');
+ this.fileActions.currentFile = $tr.find('td');
var mime = this.fileActions.getCurrentMimeType();
var type = this.fileActions.getCurrentType();
var permissions = this.fileActions.getCurrentPermissions();
var action = this.fileActions.get(mime, type, permissions)['Details'];
if (action) {
+ // also set on global object for legacy apps
+ window.FileActions.currentFile = this.fileActions.currentFile;
action(filename, {
$file: $tr,
fileList: this,
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 83926b24fee..fc5a6c18f95 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -2489,6 +2489,30 @@ describe('OCA.Files.FileList tests', function() {
expect(context.fileActions).toBeDefined();
expect(context.dir).toEqual('/subdir');
});
+ it('Clicking on an empty space of the file row will trigger the "Details" action', function() {
+ var detailsActionStub = sinon.stub();
+ fileList.setFiles(testFiles);
+ // Override the "Details" action set internally by the FileList for
+ // easier testing.
+ fileList.fileActions.registerAction({
+ mime: 'all',
+ name: 'Details',
+ permissions: OC.PERMISSION_NONE,
+ actionHandler: detailsActionStub
+ });
+ // Ensure that the action works even if fileActions.currentFile is
+ // not set.
+ fileList.fileActions.currentFile = null;
+ var $tr = fileList.findFileEl('One.txt');
+ $tr.find('td.filename a.name').click();
+ expect(detailsActionStub.calledOnce).toEqual(true);
+ expect(detailsActionStub.getCall(0).args[0]).toEqual('One.txt');
+ var context = detailsActionStub.getCall(0).args[1];
+ expect(context.$file.is($tr)).toEqual(true);
+ expect(context.fileList).toBe(fileList);
+ expect(context.fileActions).toBe(fileList.fileActions);
+ expect(context.dir).toEqual('/subdir');
+ });
it('redisplays actions when new actions have been registered', function() {
var actionStub = sinon.stub();
var readyHandler = sinon.stub();
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index e87e097e423..e53095a7de7 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -179,6 +179,7 @@ class LoginController extends Controller {
$parameters['alt_login'] = OC_App::getAlternativeLogIns();
$parameters['rememberLoginState'] = !empty($remember_login) ? $remember_login : 0;
+ $parameters['hideRemeberLoginState'] = !empty($redirect_url) && $this->session->exists('client.flow.state.token');
if (!is_null($user) && $user !== '') {
$parameters['loginName'] = $user;
diff --git a/core/templates/login.php b/core/templates/login.php
index 82827bbef03..d28c92e36ef 100644
--- a/core/templates/login.php
+++ b/core/templates/login.php
@@ -70,6 +70,7 @@ script('core', 'merged-login');
<?php } ?>
<div class="login-additional">
+ <?php if (!$_['hideRemeberLoginState']) { ?>
<div class="remember-login-container">
<?php if ($_['rememberLoginState'] === 0) { ?>
<input type="checkbox" name="remember_login" value="1" id="remember_login" class="checkbox checkbox--white">
@@ -78,6 +79,7 @@ script('core', 'merged-login');
<?php } ?>
<label for="remember_login"><?php p($l->t('Stay logged in')); ?></label>
</div>
+ <?php } ?>
<?php if (!empty($_['canResetPassword'])) { ?>
<div class="lost-password-container">
<a id="lost-password" href="<?php p($_['resetPasswordLink']); ?>">
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php
index 3c30a9d3356..5ca05d1b953 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 8f6cb85a120..a4604425544 100644
--- a/lib/private/Template/SCSSCacher.php
+++ b/lib/private/Template/SCSSCacher.php
@@ -102,8 +102,7 @@ class SCSSCacher {
$fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS));
$path = implode('/', $path);
-
- $webDir = substr($path, strlen($this->serverRoot)+1);
+ $webDir = $this->getWebDir($path, $app, $this->serverRoot, \OC::$WEBROOT);
try {
$folder = $this->appData->getFolder($app);
@@ -188,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);
@@ -283,12 +282,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);
}
@@ -315,4 +309,23 @@ 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;
}
+
+ /**
+ * Get WebDir root
+ * @param string $path the css file path
+ * @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, $appName, $serverRoot, $webRoot) {
+ // Detect if path is within server root AND if path is within an app path
+ 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
+ return str_replace($webRoot, '', $appWebPath.$appDirectoryPath);
+ }
+ return $webRoot.substr($path, strlen($serverRoot));
+ }
}
diff --git a/settings/Activity/SecurityProvider.php b/settings/Activity/SecurityProvider.php
index f0789842e82..680881b6e31 100644
--- a/settings/Activity/SecurityProvider.php
+++ b/settings/Activity/SecurityProvider.php
@@ -53,7 +53,7 @@ class SecurityProvider implements IProvider {
throw new InvalidArgumentException();
}
- $l = $this->l10n->get('core', $language);
+ $l = $this->l10n->get('settings', $language);
switch ($event->getSubject()) {
case 'twofactor_success':
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 6406e37cbcb..0a6e86ed701 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -535,20 +535,20 @@ OC.Settings.Apps = OC.Settings.Apps || {
showEmptyUpdates: function() {
$('#apps-list').addClass('hidden');
- $('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'No app updates available'));
+ $('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'App up to date'));
$('#app-list-empty-icon').removeClass('icon-search').addClass('icon-download');
},
updateApp:function(appId, element) {
var oldButtonText = element.val();
- element.val(t('settings','Updating....'));
+ element.val(t('settings','Upgrading …'));
OC.Settings.Apps.hideErrorMessage(appId);
$.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appId},function(result) {
if(!result || result.status !== 'success') {
if (result.data && result.data.message) {
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
} else {
- OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while updating app'));
+ OC.Settings.Apps.showErrorMessage(appId, t('settings','Could not upgrade app'));
}
element.val(oldButtonText);
}
@@ -584,7 +584,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
element.val(t('settings','Removing …'));
$.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appId},function(result) {
if(!result || result.status !== 'success') {
- OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while removing app'));
+ OC.Settings.Apps.showErrorMessage(appId, t('settings','Could not remove app'));
element.val(t('settings','Remove'));
} else {
OC.Settings.Apps.rebuildNavigation();
@@ -722,9 +722,9 @@ OC.Settings.Apps = OC.Settings.Apps || {
OC.dialogs.info(
t(
'settings',
- 'The app has been enabled but needs to be updated. You will be redirected to the update page in 5 seconds.'
+ 'The app has been enabled but needs to be upgraded. You will be redirected to the upgrade page in 5 seconds.'
),
- t('settings','App update'),
+ t('settings','App upgrade'),
function () {
window.location.reload();
},
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index e02b8403a2a..ddf7a865d66 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -182,12 +182,43 @@ class LoginControllerTest extends TestCase {
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => null,
+ 'hideRemeberLoginState' => false,
],
'guest'
);
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}
+ public function testShowLoginFormForFlowAuth() {
+ $this->userSession
+ ->expects($this->once())
+ ->method('isLoggedIn')
+ ->willReturn(false);
+ $this->session
+ ->expects($this->once())
+ ->method('exists')
+ ->with('client.flow.state.token')
+ ->willReturn(true);
+
+ $expectedResponse = new TemplateResponse(
+ 'core',
+ 'login',
+ [
+ 'messages' => [],
+ 'redirect_url' => 'login/flow',
+ 'loginName' => '',
+ 'user_autofocus' => true,
+ 'canResetPassword' => true,
+ 'alt_login' => [],
+ 'rememberLoginState' => 0,
+ 'resetPasswordLink' => null,
+ 'hideRemeberLoginState' => true,
+ ],
+ 'guest'
+ );
+ $this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', 'login/flow', ''));
+ }
+
/**
* @return array
*/
@@ -240,6 +271,7 @@ class LoginControllerTest extends TestCase {
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => false,
+ 'hideRemeberLoginState' => false,
],
'guest'
);
@@ -278,6 +310,7 @@ class LoginControllerTest extends TestCase {
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => false,
+ 'hideRemeberLoginState' => false,
],
'guest'
);
diff --git a/tests/Settings/Activity/SecurityProviderTest.php b/tests/Settings/Activity/SecurityProviderTest.php
index 21fc28f3c3b..552548984d7 100644
--- a/tests/Settings/Activity/SecurityProviderTest.php
+++ b/tests/Settings/Activity/SecurityProviderTest.php
@@ -87,7 +87,7 @@ class SecurityProviderTest extends TestCase {
->willReturn('security');
$this->l10n->expects($this->once())
->method('get')
- ->with('core', $lang)
+ ->with('settings', $lang)
->willReturn($l);
$this->urlGenerator->expects($this->once())
->method('imagePath')
@@ -119,7 +119,7 @@ class SecurityProviderTest extends TestCase {
->willReturn('security');
$this->l10n->expects($this->once())
->method('get')
- ->with('core', $lang)
+ ->with('settings', $lang)
->willReturn($l);
$event->expects($this->once())
->method('getSubject')
diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php
index f1e22ea600e..736c5bf7fad 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 3825bc44c59..fca9500810e 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);
}
@@ -393,4 +384,55 @@ class SCSSCacherTest extends \Test\TestCase {
$this->assertEquals(substr($result, 1), $actual);
}
+ private function randomString() {
+ 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);
+ }
+
+ 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
+ * @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);
+ $this->rrmdir($tmpDir.$path);
+ }
+
}
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index 69067f51e08..340c9c7082d 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 {
}
}
-