parent
0c6e4edc19
commit
9fbae1a174
|
@ -72,6 +72,10 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$this->depsCache
|
$this->depsCache
|
||||||
);
|
);
|
||||||
$this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]);
|
$this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]);
|
||||||
|
|
||||||
|
$this->urlGenerator->expects($this->any())
|
||||||
|
->method('getBaseUrl')
|
||||||
|
->willReturn('http://localhost/nextcloud');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessUncachedFileNoAppDataFolder() {
|
public function testProcessUncachedFileNoAppDataFolder() {
|
||||||
|
@ -84,14 +88,15 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
|
|
||||||
$fileDeps = $this->createMock(ISimpleFile::class);
|
$fileDeps = $this->createMock(ISimpleFile::class);
|
||||||
$gzfile = $this->createMock(ISimpleFile::class);
|
$gzfile = $this->createMock(ISimpleFile::class);
|
||||||
|
$filePrefix = md5('http://localhost/nextcloud') . '-';
|
||||||
|
|
||||||
$folder->method('getFile')
|
$folder->method('getFile')
|
||||||
->will($this->returnCallback(function($path) use ($file, $gzfile) {
|
->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) {
|
||||||
if ($path === 'styles.css') {
|
if ($path === $filePrefix.'styles.css') {
|
||||||
return $file;
|
return $file;
|
||||||
} else if ($path === 'styles.css.deps') {
|
} else if ($path === $filePrefix.'styles.css.deps') {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
} else if ($path === 'styles.css.gzip') {
|
} else if ($path === $filePrefix.'styles.css.gzip') {
|
||||||
return $gzfile;
|
return $gzfile;
|
||||||
} else {
|
} else {
|
||||||
$this->fail();
|
$this->fail();
|
||||||
|
@ -99,9 +104,13 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
}));
|
}));
|
||||||
$folder->expects($this->once())
|
$folder->expects($this->once())
|
||||||
->method('newFile')
|
->method('newFile')
|
||||||
->with('styles.css.deps')
|
->with($filePrefix.'styles.css.deps')
|
||||||
->willReturn($fileDeps);
|
->willReturn($fileDeps);
|
||||||
|
|
||||||
|
$this->urlGenerator->expects($this->once())
|
||||||
|
->method('getBaseUrl')
|
||||||
|
->willReturn('http://localhost/nextcloud');
|
||||||
|
|
||||||
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
|
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
|
||||||
$this->assertTrue($actual);
|
$this->assertTrue($actual);
|
||||||
}
|
}
|
||||||
|
@ -113,14 +122,15 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$file->expects($this->any())->method('getSize')->willReturn(1);
|
$file->expects($this->any())->method('getSize')->willReturn(1);
|
||||||
$fileDeps = $this->createMock(ISimpleFile::class);
|
$fileDeps = $this->createMock(ISimpleFile::class);
|
||||||
$gzfile = $this->createMock(ISimpleFile::class);
|
$gzfile = $this->createMock(ISimpleFile::class);
|
||||||
|
$filePrefix = md5('http://localhost/nextcloud') . '-';
|
||||||
|
|
||||||
$folder->method('getFile')
|
$folder->method('getFile')
|
||||||
->will($this->returnCallback(function($path) use ($file, $gzfile) {
|
->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) {
|
||||||
if ($path === 'styles.css') {
|
if ($path === $filePrefix.'styles.css') {
|
||||||
return $file;
|
return $file;
|
||||||
} else if ($path === 'styles.css.deps') {
|
} else if ($path === $filePrefix.'styles.css.deps') {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
} else if ($path === 'styles.css.gzip') {
|
} else if ($path === $filePrefix.'styles.css.gzip') {
|
||||||
return $gzfile;
|
return $gzfile;
|
||||||
}else {
|
}else {
|
||||||
$this->fail();
|
$this->fail();
|
||||||
|
@ -128,7 +138,7 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
}));
|
}));
|
||||||
$folder->expects($this->once())
|
$folder->expects($this->once())
|
||||||
->method('newFile')
|
->method('newFile')
|
||||||
->with('styles.css.deps')
|
->with($filePrefix.'styles.css.deps')
|
||||||
->willReturn($fileDeps);
|
->willReturn($fileDeps);
|
||||||
|
|
||||||
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
|
$actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core');
|
||||||
|
@ -142,14 +152,15 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$fileDeps = $this->createMock(ISimpleFile::class);
|
$fileDeps = $this->createMock(ISimpleFile::class);
|
||||||
$fileDeps->expects($this->any())->method('getSize')->willReturn(1);
|
$fileDeps->expects($this->any())->method('getSize')->willReturn(1);
|
||||||
$gzFile = $this->createMock(ISimpleFile::class);
|
$gzFile = $this->createMock(ISimpleFile::class);
|
||||||
|
$filePrefix = md5('http://localhost/nextcloud') . '-';
|
||||||
|
|
||||||
$folder->method('getFile')
|
$folder->method('getFile')
|
||||||
->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile) {
|
->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) {
|
||||||
if ($name === 'styles.css') {
|
if ($name === $filePrefix.'styles.css') {
|
||||||
return $file;
|
return $file;
|
||||||
} else if ($name === 'styles.css.deps') {
|
} else if ($name === $filePrefix.'styles.css.deps') {
|
||||||
return $fileDeps;
|
return $fileDeps;
|
||||||
} else if ($name === 'styles.css.gzip') {
|
} else if ($name === $filePrefix.'styles.css.gzip') {
|
||||||
return $gzFile;
|
return $gzFile;
|
||||||
}
|
}
|
||||||
$this->fail();
|
$this->fail();
|
||||||
|
@ -174,14 +185,14 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$fileDeps->expects($this->any())->method('getSize')->willReturn(1);
|
$fileDeps->expects($this->any())->method('getSize')->willReturn(1);
|
||||||
|
|
||||||
$gzFile = $this->createMock(ISimpleFile::class);
|
$gzFile = $this->createMock(ISimpleFile::class);
|
||||||
|
$filePrefix = md5('http://localhost/nextcloud') . '-';
|
||||||
$folder->method('getFile')
|
$folder->method('getFile')
|
||||||
->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile) {
|
->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) {
|
||||||
if ($name === 'styles.css') {
|
if ($name === $filePrefix.'styles.css') {
|
||||||
return $file;
|
return $file;
|
||||||
} else if ($name === 'styles.css.deps') {
|
} else if ($name === $filePrefix.'styles.css.deps') {
|
||||||
return $fileDeps;
|
return $fileDeps;
|
||||||
} else if ($name === 'styles.css.gzip') {
|
} else if ($name === $filePrefix.'styles.css.gzip') {
|
||||||
return $gzFile;
|
return $gzFile;
|
||||||
}
|
}
|
||||||
$this->fail();
|
$this->fail();
|
||||||
|
@ -374,7 +385,7 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$this->urlGenerator->expects($this->once())
|
$this->urlGenerator->expects($this->once())
|
||||||
->method('linkToRoute')
|
->method('linkToRoute')
|
||||||
->with('core.Css.getCss', [
|
->with('core.Css.getCss', [
|
||||||
'fileName' => 'styles.css',
|
'fileName' => md5('http://localhost/nextcloud') . '-styles.css',
|
||||||
'appName' => $appName
|
'appName' => $appName
|
||||||
])
|
])
|
||||||
->willReturn(\OC::$WEBROOT . $result);
|
->willReturn(\OC::$WEBROOT . $result);
|
||||||
|
|
Loading…
Reference in New Issue