blob: 361f93ff409023307f446e760b60bec9bbf717d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Core\Controller;
use OC\Core\Controller\ProfilePageController;
use OC\Profile\ProfileManager;
use OC\UserStatus\Manager;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IManager;
use Test\TestCase;
class ProfilePageControllerTest extends TestCase {
private IUserManager $userManager;
private ProfilePageController $controller;
protected function setUp(): void {
parent::setUp();
$request = $this->createMock(IRequest::class);
$initialStateService = $this->createMock(IInitialState::class);
$profileManager = $this->createMock(ProfileManager::class);
$shareManager = $this->createMock(IManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$userSession = $this->createMock(IUserSession::class);
$userStatusManager = $this->createMock(Manager::class);
$navigationManager = $this->createMock(INavigationManager::class);
$eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->controller = new ProfilePageController(
'core',
$request,
$initialStateService,
$profileManager,
$shareManager,
$this->userManager,
$userSession,
$userStatusManager,
$navigationManager,
$eventDispatcher,
);
}
public function testUserNotFound(): void {
$this->userManager->method('get')
->willReturn(null);
$response = $this->controller->index('bob');
$this->assertTrue($response->isThrottled());
}
public function testUserDisabled(): void {
$user = $this->createMock(IUser::class);
$user->method('isEnabled')
->willReturn(false);
$this->userManager->method('get')
->willReturn($user);
$response = $this->controller->index('bob');
$this->assertFalse($response->isThrottled());
}
}
|