aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests
diff options
context:
space:
mode:
authorAndrii Rublov <github.a@rublov.me>2024-02-25 13:48:38 +0100
committerGitHub <noreply@github.com>2024-02-25 13:48:38 +0100
commita72706f1e624f07ac9298790cb8c0806e5d0cd29 (patch)
treed8860683e4fd791ac06edfd1e3e64608a0264fe1 /apps/settings/tests
parent7142ea922729615a2e8c4ff6d6d76d33c96dafa5 (diff)
parent34c9bfc767e1bafa7c708318e4050a5f4c9a772b (diff)
downloadnextcloud-server-a72706f1e624f07ac9298790cb8c0806e5d0cd29.tar.gz
nextcloud-server-a72706f1e624f07ac9298790cb8c0806e5d0cd29.zip
Merge branch 'master' into fix/pages-titles-apps
Signed-off-by: Andrii Rublov <github.a@rublov.me>
Diffstat (limited to 'apps/settings/tests')
-rw-r--r--apps/settings/tests/Controller/AppSettingsControllerTest.php41
-rw-r--r--apps/settings/tests/Controller/UsersControllerTest.php40
2 files changed, 36 insertions, 45 deletions
diff --git a/apps/settings/tests/Controller/AppSettingsControllerTest.php b/apps/settings/tests/Controller/AppSettingsControllerTest.php
index 3e458d0ce15..198e5fc4ec4 100644
--- a/apps/settings/tests/Controller/AppSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AppSettingsControllerTest.php
@@ -37,6 +37,7 @@ use OCP\App\IAppManager;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IL10N;
use OCP\INavigationManager;
@@ -81,6 +82,8 @@ class AppSettingsControllerTest extends TestCase {
private $urlGenerator;
/** @var LoggerInterface|MockObject */
private $logger;
+ /** @var IInitialState|MockObject */
+ private $initialState;
protected function setUp(): void {
parent::setUp();
@@ -100,6 +103,7 @@ class AppSettingsControllerTest extends TestCase {
$this->installer = $this->createMock(Installer::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->logger = $this->createMock(LoggerInterface::class);
+ $this->initialState = $this->createMock(IInitialState::class);
$this->appSettingsController = new AppSettingsController(
'settings',
@@ -114,7 +118,8 @@ class AppSettingsControllerTest extends TestCase {
$this->bundleFetcher,
$this->installer,
$this->urlGenerator,
- $this->logger
+ $this->logger,
+ $this->initialState,
);
}
@@ -125,52 +130,42 @@ class AppSettingsControllerTest extends TestCase {
$expected = new JSONResponse([
[
'id' => 'auth',
- 'ident' => 'auth',
'displayName' => 'Authentication & authorization',
],
[
'id' => 'customization',
- 'ident' => 'customization',
'displayName' => 'Customization',
],
[
'id' => 'files',
- 'ident' => 'files',
'displayName' => 'Files',
],
[
'id' => 'integration',
- 'ident' => 'integration',
'displayName' => 'Integration',
],
[
'id' => 'monitoring',
- 'ident' => 'monitoring',
'displayName' => 'Monitoring',
],
[
'id' => 'multimedia',
- 'ident' => 'multimedia',
'displayName' => 'Multimedia',
],
[
'id' => 'office',
- 'ident' => 'office',
'displayName' => 'Office & text',
],
[
'id' => 'organization',
- 'ident' => 'organization',
'displayName' => 'Organization',
],
[
'id' => 'social',
- 'ident' => 'social',
'displayName' => 'Social & communication',
],
[
'id' => 'tools',
- 'ident' => 'tools',
'displayName' => 'Tools',
],
]);
@@ -198,18 +193,16 @@ class AppSettingsControllerTest extends TestCase {
->method('setActiveEntry')
->with('core_apps');
+ $this->initialState
+ ->expects($this->exactly(4))
+ ->method('provideInitialState');
+
$policy = new ContentSecurityPolicy();
$policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
$expected = new TemplateResponse('settings',
- 'settings-vue',
+ 'settings/empty',
[
- 'serverData' => [
- 'updateCount' => 0,
- 'appstoreEnabled' => true,
- 'bundles' => [],
- 'developerDocumentation' => ''
- ],
'pageTitle' => 'Settings'
],
'user');
@@ -233,18 +226,16 @@ class AppSettingsControllerTest extends TestCase {
->method('setActiveEntry')
->with('core_apps');
+ $this->initialState
+ ->expects($this->exactly(4))
+ ->method('provideInitialState');
+
$policy = new ContentSecurityPolicy();
$policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com');
$expected = new TemplateResponse('settings',
- 'settings-vue',
+ 'settings/empty',
[
- 'serverData' => [
- 'updateCount' => 0,
- 'appstoreEnabled' => false,
- 'bundles' => [],
- 'developerDocumentation' => ''
- ],
'pageTitle' => 'Settings'
],
'user');
diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php
index eddb290212a..d74f97b7013 100644
--- a/apps/settings/tests/Controller/UsersControllerTest.php
+++ b/apps/settings/tests/Controller/UsersControllerTest.php
@@ -35,6 +35,7 @@ use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\ForbiddenException;
use OC\Group\Manager;
use OC\KnownUser\KnownUserService;
+use OC\User\Manager as UserManager;
use OCA\Settings\Controller\UsersController;
use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
@@ -42,21 +43,19 @@ use OCP\Accounts\IAccountProperty;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Services\IInitialState;
use OCP\BackgroundJob\IJobList;
use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager;
use OCP\EventDispatcher\IEventDispatcher;
-use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
-use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
-use OCP\Security\ISecureRandom;
use PHPUnit\Framework\MockObject\MockObject;
/**
@@ -67,7 +66,7 @@ use PHPUnit\Framework\MockObject\MockObject;
class UsersControllerTest extends \Test\TestCase {
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var UserManager|\PHPUnit\Framework\MockObject\MockObject */
private $userManager;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userSession;
@@ -79,33 +78,29 @@ class UsersControllerTest extends \Test\TestCase {
private $l10nFactory;
/** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
private $appManager;
- /** @var IAvatarManager|\PHPUnit\Framework\MockObject\MockObject */
- private $avatarManager;
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l;
- /** @var AccountManager | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var AccountManager|\PHPUnit\Framework\MockObject\MockObject */
private $accountManager;
- /** @var ISecureRandom | \PHPUnit\Framework\MockObject\MockObject */
- private $secureRandom;
- /** @var \OCA\Settings\Mailer\NewUserMailHelper|\PHPUnit\Framework\MockObject\MockObject */
- private $newUserMailHelper;
/** @var IJobList | \PHPUnit\Framework\MockObject\MockObject */
private $jobList;
- /** @var \OC\Security\IdentityProof\Manager |\PHPUnit\Framework\MockObject\MockObject */
+ /** @var \OC\Security\IdentityProof\Manager|\PHPUnit\Framework\MockObject\MockObject */
private $securityManager;
- /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
private $encryptionManager;
/** @var KnownUserService|\PHPUnit\Framework\MockObject\MockObject */
private $knownUserService;
- /** @var IEncryptionModule | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IEncryptionModule|\PHPUnit\Framework\MockObject\MockObject */
private $encryptionModule;
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $dispatcher;
+ /** @var IInitialState|\PHPUnit\Framework\MockObject\MockObject*/
+ private $initialState;
protected function setUp(): void {
parent::setUp();
- $this->userManager = $this->createMock(IUserManager::class);
+ $this->userManager = $this->createMock(UserManager::class);
$this->groupManager = $this->createMock(Manager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->config = $this->createMock(IConfig::class);
@@ -119,6 +114,7 @@ class UsersControllerTest extends \Test\TestCase {
$this->encryptionManager = $this->createMock(IManager::class);
$this->knownUserService = $this->createMock(KnownUserService::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->initialState = $this->createMock(IInitialState::class);
$this->l->method('t')
->willReturnCallback(function ($text, $parameters = []) {
@@ -137,6 +133,10 @@ class UsersControllerTest extends \Test\TestCase {
* @return UsersController | \PHPUnit\Framework\MockObject\MockObject
*/
protected function getController($isAdmin = false, $mockedMethods = []) {
+ $this->groupManager->expects($this->any())
+ ->method('isAdmin')
+ ->willReturn($isAdmin);
+
if (empty($mockedMethods)) {
return new UsersController(
'settings',
@@ -145,7 +145,6 @@ class UsersControllerTest extends \Test\TestCase {
$this->groupManager,
$this->userSession,
$this->config,
- $isAdmin,
$this->l,
$this->mailer,
$this->l10nFactory,
@@ -155,7 +154,8 @@ class UsersControllerTest extends \Test\TestCase {
$this->jobList,
$this->encryptionManager,
$this->knownUserService,
- $this->dispatcher
+ $this->dispatcher,
+ $this->initialState,
);
} else {
return $this->getMockBuilder(UsersController::class)
@@ -167,7 +167,6 @@ class UsersControllerTest extends \Test\TestCase {
$this->groupManager,
$this->userSession,
$this->config,
- $isAdmin,
$this->l,
$this->mailer,
$this->l10nFactory,
@@ -177,9 +176,10 @@ class UsersControllerTest extends \Test\TestCase {
$this->jobList,
$this->encryptionManager,
$this->knownUserService,
- $this->dispatcher
+ $this->dispatcher,
+ $this->initialState,
]
- )->setMethods($mockedMethods)->getMock();
+ )->onlyMethods($mockedMethods)->getMock();
}
}