Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix errors from PHP 8.2 testing
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Nov 14, 2022
commit c79a6b3f62948075f7ce67a0294b0410fd61af3d
1 change: 0 additions & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public function __construct() {
$roomCalendarRoot->disableListing = $disableListing;

$publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config, $logger);
$publicCalendarRoot->disableListing = $disableListing;

$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
\OC::$server->getSystemTagManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
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;

Expand Down Expand Up @@ -78,7 +76,7 @@ public function testRun() {
[1337, \PDO::PARAM_STR, null, 'namedParameter1337']
]);

$function = $this->createMock(IQueryFunction::class);
$function = 'function1337';
$expr->expects($this->once())
->method('lt')
->with('expiration', 'namedParameter1337')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
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;
Expand Down
5 changes: 3 additions & 2 deletions apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
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;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/tests/unit/CardDAV/Activity/BackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Test\TestCase;

class BackendTest extends TestCase {

/** @var IManager|MockObject */
protected $activityManager;

Expand All @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
use Test\TestCase;

class PrincipalTest extends TestCase {

/** @var IUserManager | MockObject */
private $userManager;

Expand Down Expand Up @@ -658,12 +657,12 @@ public function testSearchPrincipalWithEnumerationDisabledDisplayname(): void {
$user2->method('getSystemEMailAddress')->willReturn('[email protected]');
$user3 = $this->createMock(IUser::class);
$user3->method('getUID')->willReturn('user3');
$user2->method('getDisplayName')->willReturn('User 22');
$user2->method('getSystemEMailAddress')->willReturn('[email protected]');
$user3->method('getDisplayName')->willReturn('User 22');
$user3->method('getSystemEMailAddress')->willReturn('[email protected]');
$user4 = $this->createMock(IUser::class);
$user4->method('getUID')->willReturn('user4');
$user2->method('getDisplayName')->willReturn('User 222');
$user2->method('getSystemEMailAddress')->willReturn('[email protected]');
$user4->method('getDisplayName')->willReturn('User 222');
$user4->method('getSystemEMailAddress')->willReturn('[email protected]');

$this->userManager->expects($this->at(0))
->method('searchDisplayName')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@
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;

Expand Down Expand Up @@ -478,7 +476,7 @@ private function buildQueryExpects($token, $return, $time) {
->with(\PDO::FETCH_ASSOC)
->willReturn($return);

$function = $this->createMock(IQueryFunction::class);
$function = 'functionToken';
$expr->expects($this->once())
->method('eq')
->with('token', 'namedParameterToken')
Expand Down
2 changes: 2 additions & 0 deletions apps/federatedfilesharing/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions apps/files_sharing/tests/ShareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ShareTest extends TestCase {

private static $tempStorage;

private string $subsubfolder = '';

protected function setUp(): void {
parent::setUp();

Expand Down Expand Up @@ -176,14 +178,14 @@ public function testShareWithGroupUniqueName() {

$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);
Expand All @@ -193,7 +195,7 @@ public function testShareWithGroupUniqueName() {
$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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
use Psr\Log\LoggerInterface;

class GroupsControllerTest extends \Test\TestCase {

/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
protected $request;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
Expand All @@ -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 */
Expand Down
8 changes: 5 additions & 3 deletions apps/settings/tests/Mailer/NewUserMailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -367,7 +369,7 @@ public function testGenerateTemplateWithPasswordResetToken() {
Install Client: https://nextcloud.com/install/#install-clients


--
--
TestCloud
This is an automatically sent email, please do not reply.
EOF;
Expand Down Expand Up @@ -601,7 +603,7 @@ public function testGenerateTemplateWithoutPasswordResetToken() {
Install Client: https://nextcloud.com/install/#install-clients


--
--
TestCloud
This is an automatically sent email, please do not reply.
EOF;
Expand Down Expand Up @@ -822,7 +824,7 @@ public function testGenerateTemplateWithoutUserId() {
Install Client: https://nextcloud.com/install/#install-clients


--
--
TestCloud
This is an automatically sent email, please do not reply.
EOF;
Expand Down
3 changes: 2 additions & 1 deletion apps/theming/tests/Settings/PersonalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class PersonalTest extends TestCase {
private ThemesService $themesService;
private IInitialState $initialStateService;
private ThemingDefaults $themingDefaults;
private Personal $admin;

/** @var ITheme[] */
private $themes;
Expand Down Expand Up @@ -144,7 +145,7 @@ private function initThemes() {
$themingDefaults->expects($this->any())
->method('getColorPrimary')
->willReturn('#0082c9');

$themingDefaults->expects($this->any())
->method('getDefaultColorPrimary')
->willReturn('#0082c9');
Expand Down
3 changes: 2 additions & 1 deletion apps/theming/tests/Themes/DyslexiaFontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
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 */
Expand Down
4 changes: 1 addition & 3 deletions lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
* @package OC\User
*/
class Session implements IUserSession, Emitter {

/** @var Manager $manager */
private $manager;

Expand Down Expand Up @@ -448,7 +447,6 @@ public function logClientIn($user,

// 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;
Expand Down Expand Up @@ -672,7 +670,7 @@ public function createSessionToken(IRequest $request, $uid, $loginName, $passwor
// 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);
Expand Down
6 changes: 4 additions & 2 deletions tests/lib/Share20/ShareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@

use OCP\Files\IRootFolder;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;

/**
* Class ShareTest
*
* @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;

Expand Down