chore(tests): Adapt tests to IUser strict typing

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
Côme Chilliet 2026-06-10 16:05:27 +02:00
parent fff30212a2
commit d881bca11f
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
5 changed files with 24 additions and 12 deletions

View file

@ -81,9 +81,13 @@ class AddExtraHeadersPluginTest extends TestCase {
$this->tree->expects($this->once())->method('getNodeForPath')
->willReturn($node);
$user = $this->createMock(IUser::class);
$node->expects($this->once())->method('getOwner')->willReturn($user);
$user->expects($this->once())->method('getUID')->willReturn($ownerId);
if ($ownerId !== null) {
$user = $this->createMock(IUser::class);
$node->expects($this->once())->method('getOwner')->willReturn($user);
$user->expects($this->once())->method('getUID')->willReturn($ownerId);
} else {
$node->expects($this->once())->method('getOwner')->willReturn(null);
}
$node->expects($this->once())->method('getDavPermissions')->willReturn($permissions);
$matcher = $this->exactly($expectedInvocations);

View file

@ -101,6 +101,10 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('getSystemEMailAddress')
->willReturn('bar@nextcloud.com');
$barUser
->expects($this->once())
->method('getDisplayName')
->willReturn('bar');
$this->userManager
->expects($this->once())
->method('search')
@ -189,6 +193,10 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('getUID')
->willReturn('foo');
$fooUser
->expects($this->once())
->method('getDisplayName')
->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')
@ -221,6 +229,10 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('getUID')
->willReturn('foo');
$fooUser
->expects($this->once())
->method('getDisplayName')
->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')

View file

@ -675,7 +675,7 @@ class UsersControllerTest extends \Test\TestCase {
}
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataTestSaveUserSettings')]
public function testSaveUserSettings(array $data, ?string $oldEmailAddress, ?string $oldDisplayName): void {
public function testSaveUserSettings(array $data, ?string $oldEmailAddress, string $oldDisplayName): void {
$controller = $this->getController();
$user = $this->createMock(IUser::class);
@ -690,7 +690,7 @@ class UsersControllerTest extends \Test\TestCase {
->with($data[IAccountManager::PROPERTY_EMAIL]['value']);
}
if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName ?? '') {
if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName) {
$user->expects($this->never())->method('setDisplayName');
} else {
$user->expects($this->once())->method('setDisplayName')
@ -775,7 +775,7 @@ class UsersControllerTest extends \Test\TestCase {
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'],
],
'john@example.com',
null
''
],
[
[
@ -783,7 +783,7 @@ class UsersControllerTest extends \Test\TestCase {
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'],
],
'JOHN@example.com',
null
''
],
];
}

View file

@ -186,10 +186,6 @@ class LocalTimeProviderTest extends TestCase {
->with('UID')
->willReturn('user1');
$user = $this->createMock(IUser::class);
$user->method('getUID')
->willReturn(null);
$entry->expects($this->never())
->method('addAction');

View file

@ -912,7 +912,7 @@ class TaskProcessingTest extends \Test\TestCase {
new ServiceRegistration('test', AsyncProvider::class)
]);
$user = $this->createMock(IUser::class);
$user->expects($this->any())->method('getUID')->willReturn(null);
$user->expects($this->any())->method('getUID')->willReturn('uid');
$mount = $this->createMock(ICachedMountInfo::class);
$mount->expects($this->any())->method('getUser')->willReturn($user);
$this->userMountCache->expects($this->any())->method('getMountsForFileId')->willReturn([$mount]);