diff options
author | Julius Haertl <jus@bitgrid.net> | 2017-02-17 16:42:07 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-25 11:39:45 +0200 |
commit | 68a63ad3f33c683d726219a508bb31de7b9ab1d0 (patch) | |
tree | 910932971b761689c8ca843860119a1df6e29573 /tests/lib/Template/SCSSCacherTest.php | |
parent | 133f3fdc9aec28383dba323d58569eddd160b0df (diff) | |
download | nextcloud-server-68a63ad3f33c683d726219a508bb31de7b9ab1d0.tar.gz nextcloud-server-68a63ad3f33c683d726219a508bb31de7b9ab1d0.zip |
Implement scss variable injection by OC_Defaults
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Add Scss variables to example theme and theming app
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Use SCSSCacher to build theming css
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Update theming.scss
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Code cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Fix tests
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Inject SCSSCacher for easier testing
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Fix typehint
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Generate absolute URLs
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Fix tests to always use absolute urls for theming images
Signed-off-by: Julius Härtl <jus@bitgrid.net>
MailheaderColor -> ColorPrimary
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/Template/SCSSCacherTest.php')
-rw-r--r-- | tests/lib/Template/SCSSCacherTest.php | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 08084e68382..fb7c6c5e034 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -23,7 +23,9 @@ namespace Test\Template; +use OC\Files\AppData\Factory; use OC\Template\SCSSCacher; +use OCA\Theming\ThemingDefaults; use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; @@ -42,6 +44,8 @@ class SCSSCacherTest extends \Test\TestCase { protected $urlGenerator; /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ protected $config; + /** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */ + protected $themingDefaults; /** @var SCSSCacher */ protected $scssCacher; /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */ @@ -51,25 +55,33 @@ class SCSSCacherTest extends \Test\TestCase { parent::setUp(); $this->logger = $this->createMock(ILogger::class); $this->appData = $this->createMock(IAppData::class); + /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */ + $factory = $this->createMock(Factory::class); + $factory->method('get')->with('css')->willReturn($this->appData); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(IConfig::class); $this->depsCache = $this->createMock(ICache::class); + $this->themingDefaults = $this->createMock(ThemingDefaults::class); $this->scssCacher = new SCSSCacher( $this->logger, - $this->appData, + $factory, $this->urlGenerator, $this->config, + $this->themingDefaults, \OC::$SERVERROOT, $this->depsCache ); + $this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]); } public function testProcessUncachedFileNoAppDataFolder() { $folder = $this->createMock(ISimpleFolder::class); - $this->appData->expects($this->once())->method('getFolder')->with('core')->willThrowException(new NotFoundException()); - $this->appData->expects($this->once())->method('newFolder')->with('core')->willReturn($folder); $file = $this->createMock(ISimpleFile::class); $file->expects($this->any())->method('getSize')->willReturn(1); + + $this->appData->expects($this->once())->method('getFolder')->with('core')->willThrowException(new NotFoundException()); + $this->appData->expects($this->once())->method('newFolder')->with('core')->willReturn($folder); + $fileDeps = $this->createMock(ISimpleFile::class); $gzfile = $this->createMock(ISimpleFile::class); @@ -127,20 +139,20 @@ class SCSSCacherTest extends \Test\TestCase { $folder = $this->createMock(ISimpleFolder::class); $this->appData->expects($this->once())->method('getFolder')->with('core')->willReturn($folder); $file = $this->createMock(ISimpleFile::class); - $file->expects($this->once())->method('getSize')->willReturn(1); $fileDeps = $this->createMock(ISimpleFile::class); $fileDeps->expects($this->any())->method('getSize')->willReturn(1); - $fileDeps->expects($this->once())->method('getContent')->willReturn('{}'); + $gzFile = $this->createMock(ISimpleFile::class); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $fileDeps) { - if ($path === 'styles.css') { + ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile) { + if ($name === 'styles.css') { return $file; - } else if ($path === 'styles.css.deps') { + } else if ($name === 'styles.css.deps') { return $fileDeps; - } else { - $this->fail(); + } else if ($name === 'styles.css.gzip') { + return $gzFile; } + $this->fail(); })); $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core'); @@ -157,23 +169,22 @@ class SCSSCacherTest extends \Test\TestCase { ->willReturn('core'); $file = $this->createMock(ISimpleFile::class); - $file->expects($this->once()) - ->method('getSize') - ->willReturn(1); - $this->depsCache->method('get') - ->with('core-styles.css.deps') - ->willReturn('{}'); + $fileDeps = $this->createMock(ISimpleFile::class); + $fileDeps->expects($this->any())->method('getSize')->willReturn(1); + + $gzFile = $this->createMock(ISimpleFile::class); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file) { - if ($path === 'styles.css') { + ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile) { + if ($name === 'styles.css') { return $file; - } else if ($path === 'styles.css.deps') { - $this->fail(); - } else { - $this->fail(); + } else if ($name === 'styles.css.deps') { + return $fileDeps; + } else if ($name === 'styles.css.gzip') { + return $gzFile; } + $this->fail(); })); $actual = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/styles.scss', 'core'); @@ -371,5 +382,4 @@ class SCSSCacherTest extends \Test\TestCase { $this->assertEquals(substr($result, 1), $actual); } - } |