From 3954a0978b768118f7b710a9174b59a79eb34a96 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 15 May 2026 20:42:41 +0200 Subject: [PATCH 1/2] refactor(NavigationManager): move navigation definitions into apps The manager itself does not need to know what hardcoded-things an app provides, instead the apps itself should handle this. Signed-off-by: Ferdinand Thiessen --- apps/appstore/appinfo/info.xml | 17 ++ apps/profile/lib/AppInfo/Application.php | 33 +++ apps/settings/appinfo/info.xml | 12 +- apps/settings/lib/AppInfo/Application.php | 80 ++++++++ core/AppInfo/Application.php | 36 +++- lib/private/NavigationManager.php | 112 ---------- tests/lib/NavigationManagerTest.php | 240 ++++++---------------- 7 files changed, 235 insertions(+), 295 deletions(-) diff --git a/apps/appstore/appinfo/info.xml b/apps/appstore/appinfo/info.xml index a1fc6a7a9272d..03e15ac8376fb 100644 --- a/apps/appstore/appinfo/info.xml +++ b/apps/appstore/appinfo/info.xml @@ -19,4 +19,21 @@ + + + + Appstore + appstore.page.viewApps + app.svg + 99 + + + + Apps + appstore.page.viewApps + app.svg + 5 + settings + + diff --git a/apps/profile/lib/AppInfo/Application.php b/apps/profile/lib/AppInfo/Application.php index ff2d3f8601683..8eb075ff59e0e 100644 --- a/apps/profile/lib/AppInfo/Application.php +++ b/apps/profile/lib/AppInfo/Application.php @@ -16,6 +16,11 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Collaboration\Reference\RenderReferenceEvent; +use OCP\INavigationManager; +use OCP\IURLGenerator; +use OCP\IUserSession; +use OCP\L10N\IFactory; +use OCP\Server; class Application extends App implements IBootstrap { public const APP_ID = 'profile'; @@ -32,5 +37,33 @@ public function register(IRegistrationContext $context): void { #[\Override] public function boot(IBootContext $context): void { + $context->injectFn($this->registerNavigationEntry(...)); + } + + /** + * Registers the navigation entry for the profile app in the user settings. + * Needed as the href is dynamic and thus we cannot use the appinfo/info.xml + */ + public function registerNavigationEntry( + INavigationManager $navigationManager, + IUserSession $userSession, + IURLGenerator $urlGenerator, + ): void { + if (!$userSession->isLoggedIn()) { + return; + } + + $l = Server::get(IFactory::class)->get('profile'); + // Profile + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'profile', + 'order' => 1, + 'href' => $urlGenerator->linkToRoute( + 'profile.ProfilePage.index', + ['targetUserId' => $userSession->getUser()->getUID()], + ), + 'name' => $l->t('View profile'), + ]); } } diff --git a/apps/settings/appinfo/info.xml b/apps/settings/appinfo/info.xml index 3b6fd2ffd9e16..dbca4af4bdf43 100644 --- a/apps/settings/appinfo/info.xml +++ b/apps/settings/appinfo/info.xml @@ -74,6 +74,16 @@ OCA\Settings\Activity\Provider OCA\Settings\Activity\SecurityProvider - + + + + + Administration settings + settings.AdminSettings.index + admin.svg + 4 + settings + + diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index ed746572ff485..27d70f8ca8ca0 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -91,7 +91,10 @@ use OCP\Group\Events\UserAddedEvent; use OCP\Group\Events\UserRemovedEvent; use OCP\IConfig; +use OCP\IGroupManager; +use OCP\INavigationManager; use OCP\IURLGenerator; +use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Mail\IMailer; use OCP\Security\ICrypto; @@ -226,5 +229,82 @@ public function register(IRegistrationContext $context): void { #[\Override] public function boot(IBootContext $context): void { + $context->injectFn($this->registerNavigationEntries(...)); + } + + /** + * Registers the navigation entries for the user settings. + * Needed as some entries are dynamic and thus we cannot use the appinfo/info.xml + * + * Registers the following entries: + * - Appearance and accessibility + * - Personal settings (named "Settings" for non-admins) + * - Accounts (only for subadmins) + * - Help & privacy (conditionally enabled based on config) + */ + public function registerNavigationEntries( + INavigationManager $navigationManager, + IURLGenerator $urlGenerator, + IUserSession $userSession, + IConfig $config, + ): void { + if ($userSession->getUser() === null) { + return; + } + + $l = Server::get(IFactory::class) + ->get('settings'); + $groupManager = Server::get(IGroupManager::class); + $isAdmin = $groupManager->isAdmin($userSession->getUser()->getUID()); + + // Accessibility settings - the URL is dynamic (route parameters) which is currently not supported by appinfo.xml + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'accessibility_settings', + 'order' => 2, + 'href' => $urlGenerator->linkToRoute('settings.PersonalSettings.index', ['section' => 'theming']), + 'name' => $l->t('Appearance and accessibility'), + 'icon' => $urlGenerator->imagePath('theming', 'accessibility-dark.svg'), + ]); + + // Personal settings - this entry is dynamic so we cannot use appinfo + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'settings_personal', + 'order' => 3, + 'href' => $urlGenerator->linkToRoute('settings.PersonalSettings.index'), + 'name' => $isAdmin + ? $l->t('Personal settings') + : $l->t('Settings'), + 'icon' => $isAdmin + ? $urlGenerator->imagePath('settings', 'personal.svg') + : $urlGenerator->imagePath('settings', 'admin.svg'), + ]); + + // User management is conditionally enabled for subadmins, but appinfo currently only supports full admins + /** @var \OC\Group\Manager $groupManager */ + $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($userSession->getUser()); + if ($isSubAdmin) { + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'core_users', + 'order' => 6, + 'href' => $urlGenerator->linkToRoute('settings.Users.usersList'), + 'name' => $l->t('Accounts'), + 'icon' => $urlGenerator->imagePath('settings', 'users.svg'), + ]); + } + + // conditionally enabled navigation entry + if ($config->getSystemValueBool('knowledgebaseenabled', true)) { + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'help', + 'order' => 99998, + 'href' => $urlGenerator->linkToRoute('settings.Help.help'), + 'name' => $l->t('Help & privacy'), + 'icon' => $urlGenerator->imagePath('settings', 'help.svg'), + ]); + } } } diff --git a/core/AppInfo/Application.php b/core/AppInfo/Application.php index 15cf42c4a5505..83edd25dd8cf9 100644 --- a/core/AppInfo/Application.php +++ b/core/AppInfo/Application.php @@ -32,6 +32,11 @@ use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\DB\Events\AddMissingIndicesEvent; use OCP\DB\Events\AddMissingPrimaryKeyEvent; +use OCP\INavigationManager; +use OCP\IURLGenerator; +use OCP\IUserSession; +use OCP\L10N\IFactory; +use OCP\Server; use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\PasswordUpdatedEvent; use OCP\User\Events\UserDeletedEvent; @@ -93,7 +98,36 @@ public function register(IRegistrationContext $context): void { #[\Override] public function boot(IBootContext $context): void { - // ... + $context->injectFn($this->registerNavigationEntries(...)); + } + + /** + * Registers the navigation entries for the core app: + * - The logout button in the settings menu + */ + public function registerNavigationEntries( + INavigationManager $navigationManager, + IUserSession $userSession, + IURLGenerator $urlGenerator, + ): void { + if (!$userSession->isLoggedIn()) { + return; + } + + $l = Server::get(IFactory::class)->get('core'); + + // Register the logout button in the user settings + $logoutUrl = \OC_User::getLogoutUrl($urlGenerator); + if ($logoutUrl !== '') { + $navigationManager->add([ + 'type' => 'settings', + 'id' => 'logout', + 'order' => 99999, + 'href' => $logoutUrl, + 'name' => $l->t('Log out'), + 'icon' => $urlGenerator->imagePath('core', 'actions/logout.svg'), + ]); + } } } diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index f1047d17a537e..041b1a7312da2 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -8,7 +8,6 @@ namespace OC; use InvalidArgumentException; -use OC\Group\Manager; use OCP\App\IAppManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -203,109 +202,6 @@ private function init(bool $resolveClosures = true): void { $this->init = true; $l = $this->l10nFac->get('lib'); - if ($this->config->getSystemValueBool('knowledgebaseenabled', true)) { - $this->add([ - 'type' => 'settings', - 'id' => 'help', - 'order' => 99998, - 'href' => $this->urlGenerator->linkToRoute('settings.Help.help'), - 'name' => $l->t('Help & privacy'), - 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), - ]); - } - - if ($this->userSession->isLoggedIn()) { - // Profile - $this->add([ - 'type' => 'settings', - 'id' => 'profile', - 'order' => 1, - 'href' => $this->urlGenerator->linkToRoute( - 'profile.ProfilePage.index', - ['targetUserId' => $this->userSession->getUser()->getUID()], - ), - 'name' => $l->t('View profile'), - ]); - - // Accessibility settings - if ($this->appManager->isEnabledForUser('theming', $this->userSession->getUser())) { - $this->add([ - 'type' => 'settings', - 'id' => 'accessibility_settings', - 'order' => 2, - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index', ['section' => 'theming']), - 'name' => $l->t('Appearance and accessibility'), - 'icon' => $this->urlGenerator->imagePath('theming', 'accessibility-dark.svg'), - ]); - } - - if ($this->isAdmin()) { - // App management - $this->add([ - 'type' => 'settings', - 'id' => 'core_apps', - 'order' => 5, - 'href' => $this->urlGenerator->linkToRoute('appstore.Page.viewApps'), - 'icon' => $this->urlGenerator->imagePath('appstore', 'app.svg'), - 'name' => $l->t('Apps'), - ]); - - // Personal settings - $this->add([ - 'type' => 'settings', - 'id' => 'settings', - 'order' => 3, - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), - 'name' => $l->t('Personal settings'), - 'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'), - ]); - - // Admin settings - $this->add([ - 'type' => 'settings', - 'id' => 'admin_settings', - 'order' => 4, - 'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview']), - 'name' => $l->t('Administration settings'), - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), - ]); - } else { - // Personal settings - $this->add([ - 'type' => 'settings', - 'id' => 'settings', - 'order' => 3, - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), - 'name' => $l->t('Settings'), - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), - ]); - } - - $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator); - if ($logoutUrl !== '') { - // Logout - $this->add([ - 'type' => 'settings', - 'id' => 'logout', - 'order' => 99999, - 'href' => $logoutUrl, - 'name' => $l->t('Log out'), - 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), - ]); - } - - if ($this->isSubadmin()) { - // User management - $this->add([ - 'type' => 'settings', - 'id' => 'core_users', - 'order' => 6, - 'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'), - 'name' => $l->t('Accounts'), - 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), - ]); - } - } $this->eventDispatcher->dispatchTyped(new LoadAdditionalEntriesEvent()); if ($this->userSession->isLoggedIn()) { @@ -388,14 +284,6 @@ private function isAdmin(): bool { return false; } - private function isSubadmin(): bool { - $user = $this->userSession->getUser(); - if ($user !== null && $this->groupManager instanceof Manager) { - return $this->groupManager->getSubAdmin()->isSubAdmin($user); - } - return false; - } - #[Override] public function setUnreadCounter(string $id, int $unreadCounter): void { $this->unreadCounters[$id] = $unreadCounter; diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 4322791e29ea3..1b2805f9c0860 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -11,8 +11,6 @@ use OC\App\AppManager; use OC\Group\Manager; use OC\NavigationManager; -use OC\Security\CSRF\CsrfTokenManager; -use OC\SubAdmin; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IGroupManager; @@ -22,7 +20,6 @@ use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Navigation\Events\LoadAdditionalEntriesEvent; -use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -260,9 +257,6 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false): vo ->with($user) ->willReturn(['test']); $this->groupManager->expects($this->any())->method('isAdmin')->willReturn($isAdmin); - $subadmin = $this->createMock(SubAdmin::class); - $subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false); - $this->groupManager->expects($this->any())->method('getSubAdmin')->willReturn($subadmin); $this->navigationManager->clear(); $this->dispatcher->expects($this->once()) @@ -275,112 +269,21 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false): vo } public static function providesNavigationConfig(): array { - $apps = [ - 'core_apps' => [ - 'id' => 'core_apps', - 'order' => 5, - 'href' => '/apps/test/', - 'icon' => '/apps/appstore/img/app.svg', - 'name' => 'Apps', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0 - ] - ]; - $defaults = [ - 'profile' => [ - 'type' => 'settings', - 'id' => 'profile', - 'order' => 1, - 'href' => '/apps/test/', - 'name' => 'View profile', - 'icon' => '', - 'active' => false, - 'classes' => '', - 'unread' => 0, - ], - 'accessibility_settings' => [ - 'type' => 'settings', - 'id' => 'accessibility_settings', - 'order' => 2, - 'href' => '/apps/test/', - 'name' => 'Appearance and accessibility', - 'icon' => '/apps/theming/img/accessibility-dark.svg', - 'active' => false, - 'classes' => '', - 'unread' => 0, - ], - 'settings' => [ - 'id' => 'settings', - 'order' => 3, - 'href' => '/apps/test/', - 'icon' => '/apps/settings/img/admin.svg', - 'name' => 'Settings', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0 - ], - 'logout' => [ - 'id' => 'logout', - 'order' => 99999, - 'href' => 'https://example.com/logout?requesttoken=' . urlencode(Server::get(CsrfTokenManager::class)->getToken()->getEncryptedValue()), - 'icon' => '/apps/core/img/actions/logout.svg', - 'name' => 'Log out', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0 - ] - ]; - $adminSettings = [ - 'accessibility_settings' => $defaults['accessibility_settings'], - 'settings' => [ - 'id' => 'settings', - 'order' => 3, - 'href' => '/apps/test/', - 'icon' => '/apps/settings/img/personal.svg', - 'name' => 'Personal settings', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0 - ], - 'admin_settings' => [ - 'id' => 'admin_settings', - 'order' => 4, - 'href' => '/apps/test/', - 'icon' => '/apps/settings/img/admin.svg', - 'name' => 'Administration settings', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0 - ] - ]; - return [ 'minimalistic' => [ - array_merge( - ['profile' => $defaults['profile']], - ['accessibility_settings' => $defaults['accessibility_settings']], - ['settings' => $defaults['settings']], - ['test' => [ - 'id' => 'test', - 'order' => 100, - 'href' => '/apps/test/', - 'icon' => '/apps/test/img/app.svg', - 'name' => 'Test', - 'active' => false, - 'type' => 'link', - 'classes' => '', - 'unread' => 0, - 'default' => true, - 'app' => 'test', - ]], - ['logout' => $defaults['logout']] - ), + ['test' => [ + 'id' => 'test', + 'order' => 100, + 'href' => '/apps/test/', + 'icon' => '/apps/test/img/app.svg', + 'name' => 'Test', + 'active' => false, + 'type' => 'link', + 'classes' => '', + 'unread' => 0, + 'default' => true, + 'app' => 'test', + ]], ['navigations' => [ 'navigation' => [ ['route' => 'test.page.index', 'name' => 'Test'] @@ -388,23 +291,17 @@ public static function providesNavigationConfig(): array { ]] ], 'minimalistic-settings' => [ - array_merge( - ['profile' => $defaults['profile']], - ['accessibility_settings' => $defaults['accessibility_settings']], - ['settings' => $defaults['settings']], - ['test' => [ - 'id' => 'test', - 'order' => 100, - 'href' => '/apps/test/', - 'icon' => '/apps/test/img/app.svg', - 'name' => 'Test', - 'active' => false, - 'type' => 'settings', - 'classes' => '', - 'unread' => 0, - ]], - ['logout' => $defaults['logout']] - ), + ['test' => [ + 'id' => 'test', + 'order' => 100, + 'href' => '/apps/test/', + 'icon' => '/apps/test/img/app.svg', + 'name' => 'Test', + 'active' => false, + 'type' => 'settings', + 'classes' => '', + 'unread' => 0, + ]], ['navigations' => [ 'navigation' => [ ['route' => 'test.page.index', 'name' => 'Test', 'type' => 'settings'] @@ -412,38 +309,32 @@ public static function providesNavigationConfig(): array { ]] ], 'with-multiple' => [ - array_merge( - ['profile' => $defaults['profile']], - ['accessibility_settings' => $defaults['accessibility_settings']], - ['settings' => $defaults['settings']], - ['test' => [ - 'id' => 'test', - 'order' => 100, + ['test' => [ + 'id' => 'test', + 'order' => 100, + 'href' => '/apps/test/', + 'icon' => '/apps/test/img/app.svg', + 'name' => 'Test', + 'active' => false, + 'type' => 'link', + 'classes' => '', + 'unread' => 0, + 'default' => false, + 'app' => 'test', + ], + 'test1' => [ + 'id' => 'test1', + 'order' => 50, 'href' => '/apps/test/', 'icon' => '/apps/test/img/app.svg', - 'name' => 'Test', + 'name' => 'Other test', 'active' => false, 'type' => 'link', 'classes' => '', 'unread' => 0, - 'default' => false, + 'default' => true, // because of order 'app' => 'test', - ], - 'test1' => [ - 'id' => 'test1', - 'order' => 50, - 'href' => '/apps/test/', - 'icon' => '/apps/test/img/app.svg', - 'name' => 'Other test', - 'active' => false, - 'type' => 'link', - 'classes' => '', - 'unread' => 0, - 'default' => true, // because of order - 'app' => 'test', - ]], - ['logout' => $defaults['logout']] - ), + ]], ['navigations' => [ 'navigation' => [ ['route' => 'test.page.index', 'name' => 'Test'], @@ -452,25 +343,19 @@ public static function providesNavigationConfig(): array { ]] ], 'admin' => [ - array_merge( - ['profile' => $defaults['profile']], - $adminSettings, - $apps, - ['test' => [ - 'id' => 'test', - 'order' => 100, - 'href' => '/apps/test/', - 'icon' => '/apps/test/img/app.svg', - 'name' => 'Test', - 'active' => false, - 'type' => 'link', - 'classes' => '', - 'unread' => 0, - 'default' => true, - 'app' => 'test', - ]], - ['logout' => $defaults['logout']] - ), + ['test' => [ + 'id' => 'test', + 'order' => 100, + 'href' => '/apps/test/', + 'icon' => '/apps/test/img/app.svg', + 'name' => 'Test', + 'active' => false, + 'type' => 'link', + 'classes' => '', + 'unread' => 0, + 'default' => true, + 'app' => 'test', + ]], ['navigations' => [ 'navigation' => [ ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test'] @@ -479,12 +364,7 @@ public static function providesNavigationConfig(): array { true ], 'no name' => [ - array_merge( - ['profile' => $defaults['profile']], - $adminSettings, - $apps, - ['logout' => $defaults['logout']] - ), + [], // nothing because the entry is not added because it has no name ['navigations' => [ 'navigation' => [ ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index'] @@ -493,12 +373,13 @@ public static function providesNavigationConfig(): array { true ], 'no admin' => [ - $defaults, + [], // nothing because user is not an admin ['navigations' => [ 'navigation' => [ ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test'] ], ]], + false, ] ]; } @@ -567,9 +448,6 @@ function (string $userId, string $appName, string $key, mixed $default = '') use ->with($user) ->willReturn(['test']); $this->groupManager->expects($this->any())->method('isAdmin')->willReturn(false); - $subadmin = $this->createMock(SubAdmin::class); - $subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false); - $this->groupManager->expects($this->any())->method('getSubAdmin')->willReturn($subadmin); $this->navigationManager->clear(); $this->dispatcher->expects($this->once()) From ebb1e3f1ecaa989d139c471b90859e8c7ec27ed9 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 16 May 2026 09:56:29 +0200 Subject: [PATCH 2/2] fix(appstore): do not set wrong app as active Signed-off-by: Ferdinand Thiessen --- apps/appstore/lib/Controller/PageController.php | 4 ---- .../tests/Controller/PageControllerTest.php | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/apps/appstore/lib/Controller/PageController.php b/apps/appstore/lib/Controller/PageController.php index f77d004626ca8..d218e612ac16a 100644 --- a/apps/appstore/lib/Controller/PageController.php +++ b/apps/appstore/lib/Controller/PageController.php @@ -23,7 +23,6 @@ use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IL10N; -use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use OCP\Server; @@ -41,7 +40,6 @@ public function __construct( private readonly IURLGenerator $urlGenerator, private readonly IInitialState $initialState, private readonly BundleFetcher $bundleFetcher, - private readonly INavigationManager $navigationManager, ) { parent::__construct(Application::APP_ID, $request); } @@ -51,8 +49,6 @@ public function __construct( #[FrontpageRoute(verb: 'GET', url: '/settings/apps/{category}', defaults: ['category' => ''], root: '')] #[FrontpageRoute(verb: 'GET', url: '/settings/apps/{category}/{id}', defaults: ['category' => '', 'id' => ''], root: '')] public function viewApps(): TemplateResponse { - $this->navigationManager->setActiveEntry('core_apps'); - $this->initialState->provideInitialState('appstoreEnabled', $this->config->getSystemValueBool('appstoreenabled', true)); $this->initialState->provideInitialState('appstoreBundles', $this->getBundles()); $this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual')); diff --git a/apps/appstore/tests/Controller/PageControllerTest.php b/apps/appstore/tests/Controller/PageControllerTest.php index 1e5edfe061f86..b41683fa616cb 100644 --- a/apps/appstore/tests/Controller/PageControllerTest.php +++ b/apps/appstore/tests/Controller/PageControllerTest.php @@ -16,7 +16,6 @@ use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IL10N; -use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use PHPUnit\Framework\MockObject\MockObject; @@ -30,8 +29,6 @@ final class PageControllerTest extends TestCase { private IConfig&MockObject $config; - private INavigationManager&MockObject $navigationManager; - private IAppManager&MockObject $appManager; private BundleFetcher&MockObject $bundleFetcher; @@ -54,7 +51,6 @@ protected function setUp(): void { ->method('t') ->willReturnArgument(0); $this->config = $this->createMock(IConfig::class); - $this->navigationManager = $this->createMock(INavigationManager::class); $this->appManager = $this->createMock(IAppManager::class); $this->bundleFetcher = $this->createMock(BundleFetcher::class); $this->installer = $this->createMock(Installer::class); @@ -70,7 +66,6 @@ protected function setUp(): void { $this->urlGenerator, $this->initialState, $this->bundleFetcher, - $this->navigationManager, ); } @@ -84,10 +79,6 @@ public function testViewApps(): void { ->method('getSystemValueBool') ->with('appstoreenabled', true) ->willReturn(true); - $this->navigationManager - ->expects($this->once()) - ->method('setActiveEntry') - ->with('core_apps'); $this->initialState ->expects($this->exactly(4)) @@ -117,10 +108,6 @@ public function testViewAppsAppstoreNotEnabled(): void { ->method('getSystemValueBool') ->with('appstoreenabled', true) ->willReturn(false); - $this->navigationManager - ->expects($this->once()) - ->method('setActiveEntry') - ->with('core_apps'); $this->initialState ->expects($this->exactly(4))