Make sure that ThemingDefaults uses the correct default values from \OC_Defaults
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
6b8341ce4b
commit
b436e43d68
|
@ -66,11 +66,11 @@ class ThemingDefaults extends \OC_Defaults {
|
||||||
public function __construct(IConfig $config,
|
public function __construct(IConfig $config,
|
||||||
IL10N $l,
|
IL10N $l,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
\OC_Defaults $defaults,
|
|
||||||
IAppData $appData,
|
IAppData $appData,
|
||||||
ICacheFactory $cacheFactory,
|
ICacheFactory $cacheFactory,
|
||||||
Util $util
|
Util $util
|
||||||
) {
|
) {
|
||||||
|
parent::__construct();
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->l = $l;
|
$this->l = $l;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
@ -78,10 +78,10 @@ class ThemingDefaults extends \OC_Defaults {
|
||||||
$this->cacheFactory = $cacheFactory;
|
$this->cacheFactory = $cacheFactory;
|
||||||
$this->util = $util;
|
$this->util = $util;
|
||||||
|
|
||||||
$this->name = $defaults->getName();
|
$this->name = parent::getName();
|
||||||
$this->url = $defaults->getBaseUrl();
|
$this->url = parent::getBaseUrl();
|
||||||
$this->slogan = $defaults->getSlogan();
|
$this->slogan = parent::getSlogan();
|
||||||
$this->color = $defaults->getColorPrimary();
|
$this->color = parent::getColorPrimary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
|
|
@ -65,25 +65,7 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||||
$this->cache = $this->createMock(ICache::class);
|
$this->cache = $this->createMock(ICache::class);
|
||||||
$this->util = $this->createMock(Util::class);
|
$this->util = $this->createMock(Util::class);
|
||||||
$this->defaults = $this->getMockBuilder(\OC_Defaults::class)
|
$this->defaults = new \OC_Defaults();
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$this->defaults
|
|
||||||
->expects($this->at(0))
|
|
||||||
->method('getName')
|
|
||||||
->willReturn('Nextcloud');
|
|
||||||
$this->defaults
|
|
||||||
->expects($this->at(1))
|
|
||||||
->method('getBaseUrl')
|
|
||||||
->willReturn('https://nextcloud.com/');
|
|
||||||
$this->defaults
|
|
||||||
->expects($this->at(2))
|
|
||||||
->method('getSlogan')
|
|
||||||
->willReturn('Safe Data');
|
|
||||||
$this->defaults
|
|
||||||
->expects($this->at(3))
|
|
||||||
->method('getColorPrimary')
|
|
||||||
->willReturn('#000');
|
|
||||||
$this->cacheFactory
|
$this->cacheFactory
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('create')
|
->method('create')
|
||||||
|
@ -93,7 +75,6 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->defaults,
|
|
||||||
$this->appData,
|
$this->appData,
|
||||||
$this->cacheFactory,
|
$this->cacheFactory,
|
||||||
$this->util
|
$this->util
|
||||||
|
@ -185,17 +166,17 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'url', 'https://nextcloud.com/')
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
||||||
->willReturn('https://nextcloud.com/');
|
->willReturn($this->defaults->getBaseUrl());
|
||||||
|
|
||||||
$this->assertEquals('https://nextcloud.com/', $this->template->getBaseUrl());
|
$this->assertEquals($this->defaults->getBaseUrl(), $this->template->getBaseUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetBaseUrlWithCustom() {
|
public function testGetBaseUrlWithCustom() {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'url', 'https://nextcloud.com/')
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
||||||
->willReturn('https://example.com/');
|
->willReturn('https://example.com/');
|
||||||
|
|
||||||
$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
|
$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
|
||||||
|
@ -205,17 +186,17 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'slogan', 'Safe Data')
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
||||||
->willReturn('Safe Data');
|
->willReturn($this->defaults->getSlogan());
|
||||||
|
|
||||||
$this->assertEquals('Safe Data', $this->template->getSlogan());
|
$this->assertEquals($this->defaults->getSlogan(), $this->template->getSlogan());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSloganWithCustom() {
|
public function testGetSloganWithCustom() {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'slogan', 'Safe Data')
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
||||||
->willReturn('My custom Slogan');
|
->willReturn('My custom Slogan');
|
||||||
|
|
||||||
$this->assertEquals('My custom Slogan', $this->template->getSlogan());
|
$this->assertEquals('My custom Slogan', $this->template->getSlogan());
|
||||||
|
@ -226,9 +207,9 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(3))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->willReturnMap([
|
->willReturnMap([
|
||||||
['theming', 'url', 'https://nextcloud.com/', 'url'],
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
||||||
['theming', 'name', 'Nextcloud', 'Name'],
|
['theming', 'name', 'Nextcloud', 'Name'],
|
||||||
['theming', 'slogan', 'Safe Data', 'Slogan'],
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> – Slogan', $this->template->getShortFooter());
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> – Slogan', $this->template->getShortFooter());
|
||||||
|
@ -239,9 +220,9 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(3))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->willReturnMap([
|
->willReturnMap([
|
||||||
['theming', 'url', 'https://nextcloud.com/', 'url'],
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
||||||
['theming', 'name', 'Nextcloud', 'Name'],
|
['theming', 'name', 'Nextcloud', 'Name'],
|
||||||
['theming', 'slogan', 'Safe Data', ''],
|
['theming', 'slogan', $this->defaults->getSlogan(), ''],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter());
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter());
|
||||||
|
@ -251,17 +232,17 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'color', '#000')
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
||||||
->willReturn('#000');
|
->willReturn($this->defaults->getColorPrimary());
|
||||||
|
|
||||||
$this->assertEquals('#000', $this->template->getColorPrimary());
|
$this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testgetColorPrimaryWithCustom() {
|
public function testgetColorPrimaryWithCustom() {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'color', '#000')
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
||||||
->willReturn('#fff');
|
->willReturn('#fff');
|
||||||
|
|
||||||
$this->assertEquals('#fff', $this->template->getColorPrimary());
|
$this->assertEquals('#fff', $this->template->getColorPrimary());
|
||||||
|
@ -328,10 +309,10 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->at(3))
|
->expects($this->at(3))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'url', 'https://nextcloud.com/')
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
||||||
->willReturn('https://nextcloud.com/');
|
->willReturn($this->defaults->getBaseUrl());
|
||||||
|
|
||||||
$this->assertSame('https://nextcloud.com/', $this->template->undo('url'));
|
$this->assertSame($this->defaults->getBaseUrl(), $this->template->undo('url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUndoSlogan() {
|
public function testUndoSlogan() {
|
||||||
|
@ -351,10 +332,10 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->at(3))
|
->expects($this->at(3))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'slogan', 'Safe Data')
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
||||||
->willReturn('Safe Data');
|
->willReturn($this->defaults->getSlogan());
|
||||||
|
|
||||||
$this->assertSame('Safe Data', $this->template->undo('slogan'));
|
$this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUndoColor() {
|
public function testUndoColor() {
|
||||||
|
@ -374,10 +355,10 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->at(3))
|
->expects($this->at(3))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('theming', 'color', '#000')
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
||||||
->willReturn('#000');
|
->willReturn($this->defaults->getColorPrimary());
|
||||||
|
|
||||||
$this->assertSame('#000', $this->template->undo('color'));
|
$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('color'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUndoDefaultAction() {
|
public function testUndoDefaultAction() {
|
||||||
|
@ -502,11 +483,11 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
$this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
|
$this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
|
||||||
$this->config->expects($this->at(2))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0');
|
$this->config->expects($this->at(2))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0');
|
||||||
$this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'backgroundMime', false)->willReturn('jpeg');
|
$this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'backgroundMime', false)->willReturn('jpeg');
|
||||||
$this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'color', null)->willReturn('#000000');
|
$this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary());
|
||||||
$this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', '#000')->willReturn('#000000');
|
$this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
|
||||||
$this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', '#000')->willReturn('#000000');
|
$this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
|
||||||
|
|
||||||
$this->util->expects($this->any())->method('invertTextColor')->with('#000000')->willReturn(false);
|
$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
|
||||||
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
|
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
|
||||||
$folder = $this->createMock(ISimpleFolder::class);
|
$folder = $this->createMock(ISimpleFolder::class);
|
||||||
$file = $this->createMock(ISimpleFile::class);
|
$file = $this->createMock(ISimpleFile::class);
|
||||||
|
@ -532,7 +513,7 @@ class ThemingDefaultsTest extends TestCase {
|
||||||
'theming-cachebuster' => '\'0\'',
|
'theming-cachebuster' => '\'0\'',
|
||||||
'image-logo' => "'absolute-custom-logo?v=0'",
|
'image-logo' => "'absolute-custom-logo?v=0'",
|
||||||
'image-login-background' => "'absolute-custom-background'",
|
'image-login-background' => "'absolute-custom-background'",
|
||||||
'color-primary' => '#000000',
|
'color-primary' => $this->defaults->getColorPrimary(),
|
||||||
'color-primary-text' => '#ffffff'
|
'color-primary-text' => '#ffffff'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -868,7 +868,6 @@ class Server extends ServerContainer implements IServerContainer {
|
||||||
$c->getConfig(),
|
$c->getConfig(),
|
||||||
$c->getL10N('theming'),
|
$c->getL10N('theming'),
|
||||||
$c->getURLGenerator(),
|
$c->getURLGenerator(),
|
||||||
new \OC_Defaults(),
|
|
||||||
$c->getAppDataDir('theming'),
|
$c->getAppDataDir('theming'),
|
||||||
$c->getMemCacheFactory(),
|
$c->getMemCacheFactory(),
|
||||||
new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
|
new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
|
||||||
|
|
Loading…
Reference in New Issue