Skip to content
Merged
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 build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4044,12 +4044,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 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 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