Skip to content

Commit c0c4443

Browse files
committed
Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent b71c920 commit c0c4443

4 files changed

Lines changed: 33 additions & 14 deletions

File tree

lib/private/Template/SCSSCacher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private function prependBaseurlPrefix($cssFile) {
320320
*/
321321
private function getWebDir($path, $appName, $serverRoot, $webRoot) {
322322
// Detect if path is within server root AND if path is within an app path
323-
if ( !strpos($path, $serverRoot) && $appWebPath = \OC_App::getAppWebPath($appName) ) {
323+
if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
324324
// Get the file path within the app directory
325325
$appDirectoryPath = explode($appName, $path)[1];
326326
// Remove the webroot

tests/lib/LegacyHelperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
use OC_Helper;
1313

1414
class LegacyHelperTest extends \Test\TestCase {
15+
/** @var string */
16+
private $originalWebRoot;
17+
18+
public function setUp() {
19+
$this->originalWebRoot = \OC::$WEBROOT;
20+
}
21+
22+
public function tearDown() {
23+
// Reset webRoot
24+
\OC::$WEBROOT = $this->originalWebRoot;
25+
}
1526

1627
/**
1728
* @dataProvider humanFileSizeProvider

tests/lib/Template/SCSSCacherTest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,6 @@ public function testGetCachedSCSS($appName, $fileName, $result) {
384384
$this->assertEquals(substr($result, 1), $actual);
385385
}
386386

387-
public function dataGetWebDir() {
388-
return [
389-
['/http/core/css', 'core', '', '/http', '/core/css'],
390-
['/http/apps/test/css', 'test', '', '/http', '/apps/test/css'],
391-
['/http/nextcloud/core/css', 'core', '/nextcloud', '/http/nextcloud', '/nextcloud/core/css'],
392-
['/http/nextcloud/apps/test/css', 'test', '/nextcloud', '/http/nextcloud', '/nextcloud/apps/test/css'],
393-
['/srv/apps2/test/css', 'test', '', '/http', '/apps2/test/css'],
394-
['/srv/apps2/test/css', 'test', '/nextcloud', '/http/nextcloud', '/apps2/test/css']
395-
];
396-
}
397-
398387
private function randomString() {
399388
return sha1(uniqid(mt_rand(), true));
400389
}
@@ -411,6 +400,19 @@ private function rrmdir($directory) {
411400
return rmdir($directory);
412401
}
413402

403+
public function dataGetWebDir() {
404+
return [
405+
// Root installation
406+
['/http/core/css', 'core', '', '/http', '/core/css'],
407+
['/http/apps/scss/css', 'scss', '', '/http', '/apps/scss/css'],
408+
['/srv/apps2/scss/css', 'scss', '', '/http', '/apps2/scss/css'],
409+
// Sub directory install
410+
['/http/nextcloud/core/css', 'core', '/nextcloud', '/http/nextcloud', '/nextcloud/core/css'],
411+
['/http/nextcloud/apps/scss/css', 'scss', '/nextcloud', '/http/nextcloud', '/nextcloud/apps/scss/css'],
412+
['/srv/apps2/scss/css', 'scss', '/nextcloud', '/http/nextcloud', '/apps2/scss/css']
413+
];
414+
}
415+
414416
/**
415417
* @param $path
416418
* @param $appName

tests/lib/UrlGeneratorTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class UrlGeneratorTest extends \Test\TestCase {
2727
private $request;
2828
/** @var IURLGenerator */
2929
private $urlGenerator;
30+
/** @var string */
31+
private $originalWebRoot;
3032

3133
public function setUp() {
3234
parent::setUp();
@@ -38,6 +40,12 @@ public function setUp() {
3840
$this->cacheFactory,
3941
$this->request
4042
);
43+
$this->originalWebRoot = \OC::$WEBROOT;
44+
}
45+
46+
public function tearDown() {
47+
// Reset webRoot
48+
\OC::$WEBROOT = $this->originalWebRoot;
4149
}
4250

4351
private function mockBaseUrl() {
@@ -47,7 +55,6 @@ private function mockBaseUrl() {
4755
$this->request->expects($this->once())
4856
->method('getServerHost')
4957
->willReturn('localhost');
50-
5158
}
5259

5360
/**
@@ -156,4 +163,3 @@ public function testGetBaseUrl() {
156163
}
157164

158165
}
159-

0 commit comments

Comments
 (0)