]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix errors from PHP 8.2 testing
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 14 Nov 2022 16:06:28 +0000 (17:06 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 14 Nov 2022 16:08:21 +0000 (17:08 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
15 files changed:
apps/dav/lib/RootCollection.php
apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
apps/dav/tests/unit/CardDAV/Activity/BackendTest.php
apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
apps/federatedfilesharing/tests/Settings/AdminTest.php
apps/files_sharing/tests/ShareTest.php
apps/provisioning_api/tests/Controller/GroupsControllerTest.php
apps/settings/tests/Mailer/NewUserMailHelperTest.php
apps/theming/tests/Settings/PersonalTest.php
apps/theming/tests/Themes/DyslexiaFontTest.php
lib/private/User/Session.php
tests/lib/Share20/ShareTest.php

index 29ab65d46a92318c8fd12b8224a1db5ad8300153..bacb550b4154ed077aa324ff46a8b4544d764f68 100644 (file)
@@ -118,7 +118,6 @@ class RootCollection extends SimpleCollection {
                $roomCalendarRoot->disableListing = $disableListing;
 
                $publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config, $logger);
-               $publicCalendarRoot->disableListing = $disableListing;
 
                $systemTagCollection = new SystemTag\SystemTagsByIdCollection(
                        \OC::$server->getSystemTagManager(),
index fd27b4d2776ba28002942eb9b86c2e6d0c299a75..d3b7ca925812d26d756a4e2fbe1b6f0c8624e970 100644 (file)
@@ -32,12 +32,10 @@ namespace OCA\DAV\Tests\unit\BackgroundJob;
 use OCA\DAV\BackgroundJob\CleanupInvitationTokenJob;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\DB\QueryBuilder\IQueryFunction;
 use OCP\IDBConnection;
 use Test\TestCase;
 
 class CleanupInvitationTokenJobTest extends TestCase {
-
        /** @var IDBConnection | \PHPUnit\Framework\MockObject\MockObject */
        private $dbConnection;
 
@@ -78,7 +76,7 @@ class CleanupInvitationTokenJobTest extends TestCase {
                                [1337, \PDO::PARAM_STR, null, 'namedParameter1337']
                        ]);
 
-               $function = $this->createMock(IQueryFunction::class);
+               $function = 'function1337';
                $expr->expects($this->once())
                        ->method('lt')
                        ->with('expiration', 'namedParameter1337')
index 991caafd59705901e6d7ebacf397760693e2ac1b..1de56b37d800ca4de77de5822308b47c6f80c1b1 100644 (file)
@@ -34,13 +34,14 @@ use OCA\DAV\BackgroundJob\PruneOutdatedSyncTokensJob;
 use OCA\DAV\CalDAV\CalDavBackend;
 use OCA\DAV\CardDAV\CardDavBackend;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\DB\Exception;
 use OCP\IConfig;
 use PHPUnit\Framework\MockObject\MockObject;
 use Psr\Log\LoggerInterface;
 use Test\TestCase;
 
 class PruneOutdatedSyncTokensJobTest extends TestCase {
+       /** @var ITimeFactory | MockObject */
+       private $timeFactory;
 
        /** @var CalDavBackend | MockObject */
        private $calDavBackend;
index 79d9376650b0e364f2b2aa056ebfd19d237083bc..e2b5390f875b693c58834706676bd70dd3dc8a81 100644 (file)
@@ -40,13 +40,11 @@ use OCP\IConfig;
 use OCP\IGroupManager;
 use OCP\IUser;
 use OCP\IUserManager;
-use OCP\IUserSession;
 use PHPUnit\Framework\MockObject\MockObject;
 use Psr\Log\LoggerInterface;
 use Test\TestCase;
 
 class ReminderServiceTest extends TestCase {
-
        /** @var Backend|MockObject */
        private $backend;
 
@@ -74,6 +72,9 @@ class ReminderServiceTest extends TestCase {
        /** @var MockObject|LoggerInterface */
        private $logger;
 
+       /** @var MockObject|Principal */
+       private $principalConnector;
+
        public const CALENDAR_DATA = <<<EOD
 BEGIN:VCALENDAR
 PRODID:-//Nextcloud calendar v1.6.4
index 4f3459233aa2e43c5c09eae8fd505e92f2940cd2..bd5660747ff6f8afc44a532fa26f3be3fa142b5a 100644 (file)
@@ -40,7 +40,6 @@ use PHPUnit\Framework\MockObject\MockObject;
 use Test\TestCase;
 
 class BackendTest extends TestCase {
-
        /** @var IManager|MockObject */
        protected $activityManager;
 
@@ -53,6 +52,9 @@ class BackendTest extends TestCase {
        /** @var IAppManager|MockObject */
        protected $appManager;
 
+       /** @var IUserManager|MockObject */
+       protected $userManager;
+
        protected function setUp(): void {
                parent::setUp();
                $this->activityManager = $this->createMock(IManager::class);
index 7cd31e3b8dd6c318a8bed0e92b35b8b221baad49..2614f5416136bfdee6d12ccc9530939fc1890b62 100644 (file)
@@ -54,7 +54,6 @@ use Sabre\DAV\PropPatch;
 use Test\TestCase;
 
 class PrincipalTest extends TestCase {
-
        /** @var IUserManager | MockObject */
        private $userManager;
 
@@ -658,12 +657,12 @@ class PrincipalTest extends TestCase {
                $user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar');
                $user3 = $this->createMock(IUser::class);
                $user3->method('getUID')->willReturn('user3');
-               $user2->method('getDisplayName')->willReturn('User 22');
-               $user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
+               $user3->method('getDisplayName')->willReturn('User 22');
+               $user3->method('getSystemEMailAddress')->willReturn('user2@foo.bar123');
                $user4 = $this->createMock(IUser::class);
                $user4->method('getUID')->willReturn('user4');
-               $user2->method('getDisplayName')->willReturn('User 222');
-               $user2->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
+               $user4->method('getDisplayName')->willReturn('User 222');
+               $user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
 
                $this->userManager->expects($this->at(0))
                        ->method('searchDisplayName')
index 576fde2d4af281ab746814e4417af5ef828eca9f..efbad5e300817e80a9af381d8195e51308589b0b 100644 (file)
@@ -37,14 +37,12 @@ use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\DB\IResult;
 use OCP\DB\QueryBuilder\IExpressionBuilder;
 use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\DB\QueryBuilder\IQueryFunction;
 use OCP\IDBConnection;
 use OCP\IRequest;
 use Sabre\VObject\ITip\Message;
 use Test\TestCase;
 
 class InvitationResponseControllerTest extends TestCase {
-
        /** @var InvitationResponseController */
        private $controller;
 
@@ -478,7 +476,7 @@ EOF;
                        ->with(\PDO::FETCH_ASSOC)
                        ->willReturn($return);
 
-               $function = $this->createMock(IQueryFunction::class);
+               $function = 'functionToken';
                $expr->expects($this->once())
                        ->method('eq')
                        ->with('token', 'namedParameterToken')
index 04761e3541023efba5fcd0209b3291911ec37feb..a9148987d387e3200b19fc6cb2b98aec46fa0a18 100644 (file)
@@ -41,6 +41,8 @@ class AdminTest extends TestCase {
        private $federatedShareProvider;
        /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
        private $gsConfig;
+       /** @var IInitialState|\PHPUnit\Framework\MockObject\MockObject */
+       private $initialState;
 
        protected function setUp(): void {
                parent::setUp();
index 45c7ceb61ef0845f84d65a9e2dc7196cb433adff..45bd5a3d707d106fc64c8c83bd47b14558703b27 100644 (file)
@@ -39,6 +39,8 @@ class ShareTest extends TestCase {
 
        private static $tempStorage;
 
+       private string $subsubfolder = '';
+
        protected function setUp(): void {
                parent::setUp();
 
@@ -176,14 +178,14 @@ class ShareTest extends TestCase {
 
                $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
                $share = $shares[0];
-               $this->assertSame('/test.txt' ,$share->getTarget());
+               $this->assertSame('/test.txt'$share->getTarget());
                $this->assertSame(19, $share->getPermissions());
 
                \OC\Files\Filesystem::rename('test.txt', 'new test.txt');
 
                $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
                $share = $shares[0];
-               $this->assertSame('/new test.txt' ,$share->getTarget());
+               $this->assertSame('/new test.txt'$share->getTarget());
                $this->assertSame(19, $share->getPermissions());
 
                $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE);
@@ -193,7 +195,7 @@ class ShareTest extends TestCase {
                $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
                $share = $shares[0];
 
-               $this->assertSame('/new test.txt' ,$share->getTarget());
+               $this->assertSame('/new test.txt'$share->getTarget());
                $this->assertSame(3, $share->getPermissions());
        }
 
index 1201099556074b94b9a93e909d05c7bdcfdb693d..5d16d58fc0a2f07c0c61cfdf63687954672c5783 100644 (file)
@@ -44,7 +44,6 @@ use OCP\UserInterface;
 use Psr\Log\LoggerInterface;
 
 class GroupsControllerTest extends \Test\TestCase {
-
        /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
        protected $request;
        /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
@@ -57,6 +56,8 @@ class GroupsControllerTest extends \Test\TestCase {
        protected $userSession;
        /** @var IAccountManager|\PHPUnit\Framework\MockObject\MockObject */
        protected $accountManager;
+       /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */
+       protected $l10nFactory;
        /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
        protected $logger;
        /** @var  SubAdmin|\PHPUnit\Framework\MockObject\MockObject */
index 2a9c1ee58ec0ebec2036217838543ce9c5a05373..eddf6fa3811aae38b4cb3c1ec4f8bbc1a66443e0 100644 (file)
@@ -55,6 +55,8 @@ class NewUserMailHelperTest extends TestCase {
        private $urlGenerator;
        /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
        private $l10n;
+       /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */
+       private $l10nFactory;
        /** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */
        private $mailer;
        /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */
@@ -367,7 +369,7 @@ Set your password: https://example.com/resetPassword/MySuperLongSecureRandomToke
 Install Client: https://nextcloud.com/install/#install-clients
 
 
--- 
+--
 TestCloud
 This is an automatically sent email, please do not reply.
 EOF;
@@ -601,7 +603,7 @@ Go to TestCloud: https://example.com/
 Install Client: https://nextcloud.com/install/#install-clients
 
 
--- 
+--
 TestCloud
 This is an automatically sent email, please do not reply.
 EOF;
@@ -822,7 +824,7 @@ Go to TestCloud: https://example.com/
 Install Client: https://nextcloud.com/install/#install-clients
 
 
--- 
+--
 TestCloud
 This is an automatically sent email, please do not reply.
 EOF;
index f8f6052a0f8513240f618b7a8f77dba1e21c593d..4e9be5ef994c9d9a10846b7110311d875d06590b 100644 (file)
@@ -54,6 +54,7 @@ class PersonalTest extends TestCase {
        private ThemesService $themesService;
        private IInitialState $initialStateService;
        private ThemingDefaults $themingDefaults;
+       private Personal $admin;
 
        /** @var ITheme[] */
        private $themes;
@@ -144,7 +145,7 @@ class PersonalTest extends TestCase {
                $themingDefaults->expects($this->any())
                        ->method('getColorPrimary')
                        ->willReturn('#0082c9');
-               
+
                $themingDefaults->expects($this->any())
                        ->method('getDefaultColorPrimary')
                        ->willReturn('#0082c9');
index 1a0f0adebec3d2dd3dfe4c2630aa8bd20a06dba8..3e92d03e4731d0702469bce4f3e3ed5bcb197b92 100644 (file)
@@ -40,10 +40,11 @@ use OCP\IUserSession;
 use PHPUnit\Framework\MockObject\MockObject;
 use Test\TestCase;
 
-
 class DyslexiaFontTest extends TestCase {
        /** @var ThemingDefaults|MockObject */
        private $themingDefaults;
+       /** @var IUserSession|MockObject */
+       private $userSession;
        /** @var IURLGenerator|MockObject */
        private $urlGenerator;
        /** @var ImageManager|MockObject */
index acf95b1e2712519c06c6a68c1d24d9773615c43e..f9ad1f72ab85d9e855ef6341b1d76c9b1828d534 100644 (file)
@@ -89,7 +89,6 @@ use Symfony\Component\EventDispatcher\GenericEvent;
  * @package OC\User
  */
 class Session implements IUserSession, Emitter {
-
        /** @var Manager $manager */
        private $manager;
 
@@ -448,7 +447,6 @@ class Session implements IUserSession, Emitter {
 
                // Try to login with this username and password
                if (!$this->login($user, $password)) {
-
                        // Failed, maybe the user used their email address
                        if (!filter_var($user, FILTER_VALIDATE_EMAIL)) {
                                return false;
@@ -672,7 +670,7 @@ class Session implements IUserSession, Emitter {
                        // User does not exist
                        return false;
                }
-               $name = isset($request->server['HTTP_USER_AGENT']) ? utf8_encode($request->server['HTTP_USER_AGENT']) : 'unknown browser';
+               $name = isset($request->server['HTTP_USER_AGENT']) ? mb_convert_encoding($request->server['HTTP_USER_AGENT'], 'UTF-8', 'ISO-8859-1') : 'unknown browser';
                try {
                        $sessionId = $this->session->getId();
                        $pwd = $this->getPassword($password);
index 7d4dc6de2d6daea6736e9c1fa8bb1c64f4b0f3d5..b2419e0768321c11cd50d449d83760a323e80d4d 100644 (file)
@@ -23,6 +23,7 @@ namespace Test\Share20;
 
 use OCP\Files\IRootFolder;
 use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
 
 /**
  * Class ShareTest
@@ -30,9 +31,10 @@ use OCP\IUserManager;
  * @package Test\Share20
  */
 class ShareTest extends \Test\TestCase {
-
-       /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var IRootFolder|MockObject */
        protected $rootFolder;
+       /** @var IUserManager|MockObject */
+       protected $userManager;
        /** @var \OCP\Share\IShare */
        protected $share;