Skip to content

Commit 9faf386

Browse files
Merge pull request #52913 from nextcloud/debt/noid/use-logical-operator
2 parents 3943f08 + df9a275 commit 9faf386

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

build/psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,12 +4044,6 @@
40444044
</TypeDoesNotContainNull>
40454045
</file>
40464046
<file src="lib/private/Group/Group.php">
4047-
<InvalidArgument>
4048-
<code><![CDATA[bool]]></code>
4049-
</InvalidArgument>
4050-
<InvalidOperand>
4051-
<code><![CDATA[$hide]]></code>
4052-
</InvalidOperand>
40534047
<LessSpecificReturnStatement>
40544048
<code><![CDATA[$users]]></code>
40554049
</LessSpecificReturnStatement>

lib/private/Group/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public function canAddUser(): bool {
377377
*/
378378
public function hideFromCollaboration(): bool {
379379
return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) {
380-
return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
380+
return $hide || ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
381381
}, false);
382382
}
383383
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace Test\Group;
11+
12+
use OC\Group\Group;
13+
use OCP\EventDispatcher\IEventDispatcher;
14+
use OCP\Group\Backend\ABackend;
15+
use OCP\Group\Backend\IHideFromCollaborationBackend;
16+
use OCP\IUserManager;
17+
use PHPUnit\Framework\MockObject\MockObject;
18+
use Test\TestCase;
19+
20+
abstract class HideFromCollaborationBackendTest extends ABackend implements IHideFromCollaborationBackend {
21+
22+
}
23+
24+
class HideFromCollaborationTest extends TestCase {
25+
26+
private IUserManager&MockObject $userManager;
27+
private IEventDispatcher&MockObject $dispatcher;
28+
29+
protected function setUp(): void {
30+
parent::setUp();
31+
32+
$this->userManager = $this->createMock(IUserManager::class);
33+
$this->dispatcher = $this->createMock(IEventDispatcher::class);
34+
}
35+
36+
37+
public function testHideFromCollaboration(): void {
38+
// Arrange
39+
$backend1 = $this->createMock(HideFromCollaborationBackendTest::class);
40+
$backend1->method('hideGroup')
41+
->willReturn(false);
42+
$backend2 = $this->createMock(HideFromCollaborationBackendTest::class);
43+
$backend2->method('hideGroup')
44+
->willReturn(true);
45+
$group = new Group('group1', [$backend1, $backend2], $this->dispatcher, $this->userManager);
46+
47+
// Act
48+
$result = $group->hideFromCollaboration();
49+
50+
// Assert
51+
$this->assertTrue($result);
52+
}
53+
}

0 commit comments

Comments
 (0)