Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function __construct(
private CategoryFetcher $categoryFetcher,
private AppFetcher $appFetcher,
private IFactory $l10nFactory,
private IGroupManager $groupManager,
private BundleFetcher $bundleFetcher,
private Installer $installer,
private IURLGenerator $urlGenerator,
Expand All @@ -95,6 +96,15 @@ public function viewApps(): TemplateResponse {
$this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual'));
$this->initialState->provideInitialState('appstoreUpdateCount', count($this->getAppsWithUpdates()));

$groups = array_map(function (IGroup $group) {
return [
'id' => $group->getGID(),
'name' => $group->getDisplayName(),
];
}, $this->groupManager->search('', 5));
Comment on lines +99 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$groups = array_map(function (IGroup $group) {
return [
'id' => $group->getGID(),
'name' => $group->getDisplayName(),
];
}, $this->groupManager->search('', 5));
$groups = array_map(static fn (IGroup $group): array => [
'id' => $group->getGID(),
'name' => $group->getDisplayName(),
], $this->groupManager->search('', 5));


$this->initialState->provideInitialState('usersSettings', [ 'systemGroups' => $groups]);

if ($this->appManager->isEnabledForAnyone('app_api')) {
try {
Server::get(ExAppsPageService::class)->provideAppApiState($this->initialState);
Expand Down
23 changes: 21 additions & 2 deletions apps/settings/tests/Controller/AppSettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use OCP\Files\AppData\IAppDataFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IRequest;
Expand All @@ -45,6 +47,7 @@ class AppSettingsControllerTest extends TestCase {
private CategoryFetcher&MockObject $categoryFetcher;
private AppFetcher&MockObject $appFetcher;
private IFactory&MockObject $l10nFactory;
private IGroupManager&MockObject $groupManager;
private BundleFetcher&MockObject $bundleFetcher;
private Installer&MockObject $installer;
private IURLGenerator&MockObject $urlGenerator;
Expand All @@ -70,6 +73,7 @@ protected function setUp(): void {
$this->categoryFetcher = $this->createMock(CategoryFetcher::class);
$this->appFetcher = $this->createMock(AppFetcher::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->bundleFetcher = $this->createMock(BundleFetcher::class);
$this->installer = $this->createMock(Installer::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
Expand All @@ -89,6 +93,7 @@ protected function setUp(): void {
$this->categoryFetcher,
$this->appFetcher,
$this->l10nFactory,
$this->groupManager,
$this->bundleFetcher,
$this->installer,
$this->urlGenerator,
Expand Down Expand Up @@ -168,9 +173,16 @@ public function testViewApps(): void {
->expects($this->once())
->method('setActiveEntry')
->with('core_apps');
$this->groupManager->expects($this->once())
->method('search')
->with($this->equalTo(''), $this->equalTo(5))
->willReturn([
$this->createMock(IGroup::class),
$this->createMock(IGroup::class),
]);

$this->initialState
->expects($this->exactly(4))
->expects($this->exactly(5))
->method('provideInitialState');

$policy = new ContentSecurityPolicy();
Expand Down Expand Up @@ -201,9 +213,16 @@ public function testViewAppsAppstoreNotEnabled(): void {
->expects($this->once())
->method('setActiveEntry')
->with('core_apps');
$this->groupManager->expects($this->once())
->method('search')
->with($this->equalTo(''), $this->equalTo(5))
->willReturn([
$this->createMock(IGroup::class),
$this->createMock(IGroup::class),
]);

$this->initialState
->expects($this->exactly(4))
->expects($this->exactly(5))
->method('provideInitialState');

$policy = new ContentSecurityPolicy();
Expand Down
Loading