Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

use logical operator for hideFromCollaboration #52913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
Loading
from
Draft
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
6 changes: 0 additions & 6 deletions 6 build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4098,12 +4098,6 @@
</TypeDoesNotContainNull>
</file>
<file src="lib/private/Group/Group.php">
<InvalidArgument>
<code><![CDATA[bool]]></code>
</InvalidArgument>
<InvalidOperand>
<code><![CDATA[$hide]]></code>
</InvalidOperand>
<LessSpecificReturnStatement>
<code><![CDATA[$users]]></code>
</LessSpecificReturnStatement>
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/private/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public function canAddUser(): bool {
*/
public function hideFromCollaboration(): bool {
return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) {
return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
return $hide || ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
}, false);
}
}
53 changes: 53 additions & 0 deletions 53 tests/lib/Group/HideFromCollaborationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace Test\Group;

use OC\Group\Group;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Group\Backend\ABackend;
use OCP\Group\Backend\IHideFromCollaborationBackend;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

abstract class HideFromCollaborationBackendTest extends ABackend implements IHideFromCollaborationBackend {

}

class HideFromCollaborationTest extends TestCase {

private IUserManager&MockObject $userManager;
private IEventDispatcher&MockObject $dispatcher;

protected function setUp(): void {
parent::setUp();

$this->userManager = $this->createMock(IUserManager::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
}


public function testHideFromCollaboration(): void {
// Arrange
$backend1 = $this->createMock(HideFromCollaborationBackendTest::class);
$backend1->method('hideGroup')
->willReturn(false);
$backend2 = $this->createMock(HideFromCollaborationBackendTest::class);
$backend2->method('hideGroup')
->willReturn(true);
$group = new Group('group1', [$backend1, $backend2], $this->dispatcher, $this->userManager);

// Act
$result = $group->hideFromCollaboration();

// Assert
$this->assertTrue($result);
}
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.