Browse Source

Fix tests

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
pull/34576/head
John Molakvoæ 3 years ago
parent
commit
746710ad5b
No known key found for this signature in database GPG Key ID: 60C25B8C072916CF
  1. 5
      apps/theming/css/default.css
  2. 11
      apps/theming/tests/Service/ThemesServiceTest.php
  3. 2
      apps/theming/tests/Settings/AdminTest.php
  4. 16
      apps/theming/tests/Settings/PersonalTest.php
  5. 7
      apps/theming/tests/Themes/DefaultThemeTest.php
  6. 5
      apps/theming/tests/Themes/DyslexiaFontTest.php
  7. 20
      apps/theming/tests/ThemingDefaultsTest.php

5
apps/theming/css/default.css

@ -51,10 +51,11 @@
--header-menu-item-height: 44px; --header-menu-item-height: 44px;
--header-menu-profile-item-height: 66px; --header-menu-profile-item-height: 66px;
--breakpoint-mobile: 1024px; --breakpoint-mobile: 1024px;
--primary-invert-if-bright: no;
--background-invert-if-dark: no; --background-invert-if-dark: no;
--background-invert-if-bright: invert(100%); --background-invert-if-bright: invert(100%);
--image-main-background: url('/core/img/app-background.jpg');
--image-background: url('/core/img/app-background.jpg');
--color-background-plain: #0082c9;
--primary-invert-if-bright: no;
--color-primary: #00639a; --color-primary: #00639a;
--color-primary-default: #0082c9; --color-primary-default: #0082c9;
--color-primary-text: #ffffff; --color-primary-text: #ffffff;

11
apps/theming/tests/Service/ThemesServiceTest.php

@ -34,11 +34,9 @@ use OCA\Theming\Service\ThemesService;
use OCA\Theming\Themes\LightTheme; use OCA\Theming\Themes\LightTheme;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util; use OCA\Theming\Util;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest;
use OCP\App\IAppManager;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUser; use OCP\IUser;
use OCP\IUserSession; use OCP\IUserSession;
@ -280,6 +278,7 @@ class ThemesServiceTest extends TestCase {
$urlGenerator = $this->createMock(IURLGenerator::class); $urlGenerator = $this->createMock(IURLGenerator::class);
$imageManager = $this->createMock(ImageManager::class); $imageManager = $this->createMock(ImageManager::class);
$l10n = $this->createMock(IL10N::class); $l10n = $this->createMock(IL10N::class);
$appManager = $this->createMock(IAppManager::class);
$this->themes = [ $this->themes = [
'default' => new DefaultTheme( 'default' => new DefaultTheme(
@ -290,6 +289,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
'light' => new LightTheme( 'light' => new LightTheme(
$util, $util,
@ -299,6 +299,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
'dark' => new DarkTheme( 'dark' => new DarkTheme(
$util, $util,
@ -308,6 +309,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
'light-highcontrast' => new HighContrastTheme( 'light-highcontrast' => new HighContrastTheme(
$util, $util,
@ -317,6 +319,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
'dark-highcontrast' => new DarkHighContrastTheme( 'dark-highcontrast' => new DarkHighContrastTheme(
$util, $util,
@ -326,6 +329,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
'opendyslexic' => new DyslexiaFont( 'opendyslexic' => new DyslexiaFont(
$util, $util,
@ -335,6 +339,7 @@ class ThemesServiceTest extends TestCase {
$imageManager, $imageManager,
$this->config, $this->config,
$l10n, $l10n,
$appManager,
), ),
]; ];
} }

2
apps/theming/tests/Settings/AdminTest.php

@ -117,6 +117,7 @@ class AdminTest extends TestCase {
'images' => [], 'images' => [],
'imprintUrl' => '', 'imprintUrl' => '',
'privacyUrl' => '', 'privacyUrl' => '',
'userThemingDisabled' => false,
]; ];
$expected = new TemplateResponse('theming', 'settings-admin', $params, ''); $expected = new TemplateResponse('theming', 'settings-admin', $params, '');
@ -176,6 +177,7 @@ class AdminTest extends TestCase {
'images' => [], 'images' => [],
'imprintUrl' => '', 'imprintUrl' => '',
'privacyUrl' => '', 'privacyUrl' => '',
'userThemingDisabled' => false
]; ];
$expected = new TemplateResponse('theming', 'settings-admin', $params, ''); $expected = new TemplateResponse('theming', 'settings-admin', $params, '');

16
apps/theming/tests/Settings/PersonalTest.php

@ -40,6 +40,7 @@ use OCA\Theming\Themes\LightTheme;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util; use OCA\Theming\Util;
use OCA\Theming\ITheme; use OCA\Theming\ITheme;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState; use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig; use OCP\IConfig;
@ -52,6 +53,7 @@ class PersonalTest extends TestCase {
private IConfig $config; private IConfig $config;
private ThemesService $themesService; private ThemesService $themesService;
private IInitialState $initialStateService; private IInitialState $initialStateService;
private ThemingDefaults $themingDefaults;
/** @var ITheme[] */ /** @var ITheme[] */
private $themes; private $themes;
@ -61,6 +63,7 @@ class PersonalTest extends TestCase {
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->themesService = $this->createMock(ThemesService::class); $this->themesService = $this->createMock(ThemesService::class);
$this->initialStateService = $this->createMock(IInitialState::class); $this->initialStateService = $this->createMock(IInitialState::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->initThemes(); $this->initThemes();
@ -73,7 +76,8 @@ class PersonalTest extends TestCase {
Application::APP_ID, Application::APP_ID,
$this->config, $this->config,
$this->themesService, $this->themesService,
$this->initialStateService
$this->initialStateService,
$this->themingDefaults,
); );
} }
@ -107,11 +111,12 @@ class PersonalTest extends TestCase {
->with('enforce_theme', '') ->with('enforce_theme', '')
->willReturn($enforcedTheme); ->willReturn($enforcedTheme);
$this->initialStateService->expects($this->exactly(2))
$this->initialStateService->expects($this->exactly(3))
->method('provideInitialState') ->method('provideInitialState')
->withConsecutive( ->withConsecutive(
['themes', $themesState], ['themes', $themesState],
['enforceTheme', $enforcedTheme], ['enforceTheme', $enforcedTheme],
['isUserThemingDisabled', false]
); );
$expected = new TemplateResponse('theming', 'settings-personal'); $expected = new TemplateResponse('theming', 'settings-personal');
@ -134,6 +139,7 @@ class PersonalTest extends TestCase {
$imageManager = $this->createMock(ImageManager::class); $imageManager = $this->createMock(ImageManager::class);
$config = $this->createMock(IConfig::class); $config = $this->createMock(IConfig::class);
$l10n = $this->createMock(IL10N::class); $l10n = $this->createMock(IL10N::class);
$appManager = $this->createMock(IAppManager::class);
$themingDefaults->expects($this->any()) $themingDefaults->expects($this->any())
->method('getColorPrimary') ->method('getColorPrimary')
@ -152,6 +158,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
'light' => new LightTheme( 'light' => new LightTheme(
$util, $util,
@ -161,6 +168,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
'dark' => new DarkTheme( 'dark' => new DarkTheme(
$util, $util,
@ -170,6 +178,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
'light-highcontrast' => new HighContrastTheme( 'light-highcontrast' => new HighContrastTheme(
$util, $util,
@ -179,6 +188,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
'dark-highcontrast' => new DarkHighContrastTheme( 'dark-highcontrast' => new DarkHighContrastTheme(
$util, $util,
@ -188,6 +198,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
'opendyslexic' => new DyslexiaFont( 'opendyslexic' => new DyslexiaFont(
$util, $util,
@ -197,6 +208,7 @@ class PersonalTest extends TestCase {
$imageManager, $imageManager,
$config, $config,
$l10n, $l10n,
$appManager,
), ),
]; ];
} }

7
apps/theming/tests/Themes/DefaultThemeTest.php

@ -28,6 +28,7 @@ use OCA\Theming\ITheme;
use OCA\Theming\Themes\DefaultTheme; use OCA\Theming\Themes\DefaultTheme;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util; use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\Files\IAppData; use OCP\Files\IAppData;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
@ -48,6 +49,8 @@ class DefaultThemeTest extends TestCase {
private $config; private $config;
/** @var IL10N|MockObject */ /** @var IL10N|MockObject */
private $l10n; private $l10n;
/** @var IAppManager|MockObject */
private $appManager;
private DefaultTheme $defaultTheme; private DefaultTheme $defaultTheme;
@ -58,10 +61,11 @@ class DefaultThemeTest extends TestCase {
$this->imageManager = $this->createMock(ImageManager::class); $this->imageManager = $this->createMock(ImageManager::class);
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class); $this->l10n = $this->createMock(IL10N::class);
$this->appManager = $this->createMock(IAppManager::class);
$util = new Util( $util = new Util(
$this->config, $this->config,
$this->createMock(AppManager::class),
$this->appManager,
$this->createMock(IAppData::class) $this->createMock(IAppData::class)
); );
@ -97,6 +101,7 @@ class DefaultThemeTest extends TestCase {
$this->imageManager, $this->imageManager,
$this->config, $this->config,
$this->l10n, $this->l10n,
$this->appManager,
); );
parent::setUp(); parent::setUp();

5
apps/theming/tests/Themes/DyslexiaFontTest.php

@ -29,6 +29,7 @@ use OCA\Theming\ITheme;
use OCA\Theming\Themes\DyslexiaFont; use OCA\Theming\Themes\DyslexiaFont;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util; use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\Files\IAppData; use OCP\Files\IAppData;
use OCP\ICacheFactory; use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
@ -51,6 +52,8 @@ class DyslexiaFontTest extends TestCase {
private $config; private $config;
/** @var IL10N|MockObject */ /** @var IL10N|MockObject */
private $l10n; private $l10n;
/** @var IAppManager|MockObject */
private $appManager;
private DyslexiaFont $dyslexiaFont; private DyslexiaFont $dyslexiaFont;
@ -60,6 +63,7 @@ class DyslexiaFontTest extends TestCase {
$this->imageManager = $this->createMock(ImageManager::class); $this->imageManager = $this->createMock(ImageManager::class);
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class); $this->l10n = $this->createMock(IL10N::class);
$this->appManager = $this->createMock(IAppManager::class);
$util = new Util( $util = new Util(
$this->config, $this->config,
@ -104,6 +108,7 @@ class DyslexiaFontTest extends TestCase {
$this->imageManager, $this->imageManager,
$this->config, $this->config,
$this->l10n, $this->l10n,
$this->appManager,
); );
parent::setUp(); parent::setUp();

20
apps/theming/tests/ThemingDefaultsTest.php

@ -424,20 +424,30 @@ class ThemingDefaultsTest extends TestCase {
public function testGetColorPrimaryWithDefault() { public function testGetColorPrimaryWithDefault() {
$this->config $this->config
->expects($this->once())
->expects($this->at(0))
->method('getAppValue') ->method('getAppValue')
->with('theming', 'color', null) ->with('theming', 'color', null)
->willReturn($this->defaults->getColorPrimary()); ->willReturn($this->defaults->getColorPrimary());
$this->config
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'disable-user-theming', 'no')
->willReturn('no');
$this->assertEquals($this->defaults->getColorPrimary(), $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->at(0))
->method('getAppValue') ->method('getAppValue')
->with('theming', 'color', null) ->with('theming', 'color', null)
->willReturn('#fff'); ->willReturn('#fff');
$this->config
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'disable-user-theming', 'no')
->willReturn('no');
$this->assertEquals('#fff', $this->template->getColorPrimary()); $this->assertEquals('#fff', $this->template->getColorPrimary());
} }
@ -613,14 +623,16 @@ class ThemingDefaultsTest extends TestCase {
->method('deleteAppValue') ->method('deleteAppValue')
->with('theming', 'color'); ->with('theming', 'color');
$this->config $this->config
->expects($this->exactly(2))
->expects($this->exactly(3))
->method('getAppValue') ->method('getAppValue')
->withConsecutive( ->withConsecutive(
['theming', 'cachebuster', '0'], ['theming', 'cachebuster', '0'],
['theming', 'color', null], ['theming', 'color', null],
['theming', 'disable-user-theming', 'no'],
)->willReturnOnConsecutiveCalls( )->willReturnOnConsecutiveCalls(
'15', '15',
$this->defaults->getColorPrimary(), $this->defaults->getColorPrimary(),
'no',
); );
$this->config $this->config
->expects($this->once()) ->expects($this->once())

Loading…
Cancel
Save