From 2a684f674164640d917a4fd1b3631b6ed3b36eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 26 Oct 2022 12:50:08 +0200 Subject: [PATCH 1/6] Fix some phpunit test warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../unit/BackgroundJob/CleanupInvitationTokenJobTest.php | 2 +- apps/dav/tests/unit/CalDAV/CalendarImplTest.php | 4 ++-- .../unit/Controller/InvitationResponseControllerTest.php | 2 +- tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php index fd27b4d2776ba..295949bdc918d 100644 --- a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php @@ -82,7 +82,7 @@ public function testRun() { $expr->expects($this->once()) ->method('lt') ->with('expiration', 'namedParameter1337') - ->willReturn($function); + ->willReturn((string)$function); $this->dbConnection->expects($this->once()) ->method('getQueryBuilder') diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 6842bdadb53f0..56aef20ca74a6 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -152,7 +152,7 @@ public function testHandleImipMessage(): void { UID:aUniqueUid SEQUENCE:2 REQUEST-STATUS:2.0;Success -%sEND:VEVENT +END:VEVENT END:VCALENDAR EOF; @@ -190,7 +190,7 @@ public function testHandleImipMessageNoCalendarUri(): void { UID:aUniqueUid SEQUENCE:2 REQUEST-STATUS:2.0;Success -%sEND:VEVENT +END:VEVENT END:VCALENDAR EOF; diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php index 576fde2d4af28..3e6886964c95f 100644 --- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php +++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php @@ -482,7 +482,7 @@ private function buildQueryExpects($token, $return, $time) { $expr->expects($this->once()) ->method('eq') ->with('token', 'namedParameterToken') - ->willReturn($function); + ->willReturn((string)$function); $this->dbConnection->expects($this->once()) ->method('getQueryBuilder') diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index ce739a74bb88f..197cb46a592be 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -36,6 +36,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; +use OCP\IDBConnection; use OCP\Security\ICrypto; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -73,9 +74,6 @@ protected function setUp(): void { ['openssl', [], []], ]); $this->db = $this->createMock(IDBConnection::class); - $this->db->method('atomic')->willReturnCallback(function ($cb) { - return $cb(); - }); $this->logger = $this->createMock(LoggerInterface::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->time = 1313131; From 908b7aa70af4417a0011e1b09ba44dc9b50792f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 28 Oct 2022 11:19:13 +0200 Subject: [PATCH 2/6] Attempt to fix CalendarImpl tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/dav/lib/CalDAV/CalendarImpl.php | 16 +- .../InvitationResponseServer.php | 6 +- .../tests/unit/CalDAV/CalendarImplTest.php | 138 ++++++++++++++---- tests/lib/Encryption/UtilTest.php | 2 + 4 files changed, 123 insertions(+), 39 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index 79a5626f322c1..f9e9c58480832 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -147,7 +147,7 @@ public function createFromString(string $name, string $calendarData): void { $server = new InvitationResponseServer(false); /** @var CustomPrincipalPlugin $plugin */ - $plugin = $server->server->getPlugin('auth'); + $plugin = $server->getServer()->getPlugin('auth'); // we're working around the previous implementation // that only allowed the public system principal to be used // so set the custom principal here @@ -163,14 +163,14 @@ public function createFromString(string $name, string $calendarData): void { // Force calendar change URI /** @var Schedule\Plugin $schedulingPlugin */ - $schedulingPlugin = $server->server->getPlugin('caldav-schedule'); + $schedulingPlugin = $server->getServer()->getPlugin('caldav-schedule'); $schedulingPlugin->setPathOfCalendarObjectChange($fullCalendarFilename); $stream = fopen('php://memory', 'rb+'); fwrite($stream, $calendarData); rewind($stream); try { - $server->server->createFile($fullCalendarFilename, $stream); + $server->getServer()->createFile($fullCalendarFilename, $stream); } catch (Conflict $e) { throw new CalendarException('Could not create new calendar event: ' . $e->getMessage(), 0, $e); } finally { @@ -182,10 +182,10 @@ public function createFromString(string $name, string $calendarData): void { * @throws CalendarException */ public function handleIMipMessage(string $name, string $calendarData): void { - $server = new InvitationResponseServer(false); + $server = $this->getInvitationResponseServer(); /** @var CustomPrincipalPlugin $plugin */ - $plugin = $server->server->getPlugin('auth'); + $plugin = $server->getServer()->getPlugin('auth'); // we're working around the previous implementation // that only allowed the public system principal to be used // so set the custom principal here @@ -196,7 +196,7 @@ public function handleIMipMessage(string $name, string $calendarData): void { } // Force calendar change URI /** @var Schedule\Plugin $schedulingPlugin */ - $schedulingPlugin = $server->server->getPlugin('caldav-schedule'); + $schedulingPlugin = $server->getServer()->getPlugin('caldav-schedule'); // Let sabre handle the rest $iTipMessage = new Message(); /** @var VCalendar $vObject */ @@ -232,4 +232,8 @@ public function handleIMipMessage(string $name, string $calendarData): void { $iTipMessage->message = $vObject; $schedulingPlugin->scheduleLocalDelivery($iTipMessage); } + + public function getInvitationResponseServer() { + return new InvitationResponseServer(false); + } } diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php index a85892443cc45..c2e31f7bdc439 100644 --- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php +++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php @@ -127,7 +127,11 @@ public function handleITipMessage(Message $iTipMessage) { public function isExternalAttendee(string $principalUri): bool { /** @var \Sabre\DAVACL\Plugin $aclPlugin */ - $aclPlugin = $this->server->getPlugin('acl'); + $aclPlugin = $this->getServer()->getPlugin('acl'); return $aclPlugin->getPrincipalByUri($principalUri) === null; } + + public function getServer() { + return $this->server; + } } diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 56aef20ca74a6..b504e8b124915 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -31,8 +31,17 @@ use OCA\DAV\CalDAV\CalendarImpl; use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; use OCA\DAV\CalDAV\Schedule\Plugin; +use OCP\Calendar\Exceptions\CalendarException; use PHPUnit\Framework\MockObject\MockObject; +use Sabre\DAV\Server; +use Sabre\VObject\Component\VCalendar; +use Sabre\VObject\Component\VEvent; +use Sabre\VObject\ITip\Message; +use Sabre\VObject\Reader; +/** + * @group DB + */ class CalendarImplTest extends \Test\TestCase { /** @var CalendarImpl */ @@ -132,14 +141,43 @@ public function testGetPermissionAll() { } public function testHandleImipMessage(): void { - $invitationResponseServer = $this->createConfiguredMock(InvitationResponseServer::class, [ - 'server' => $this->createConfiguredMock(CalDavBackend::class, [ - 'getPlugin' => [ - 'auth' => $this->createMock(CustomPrincipalPlugin::class), - 'schedule' => $this->createMock(Plugin::class) - ] - ]) - ]); + /** @var CustomPrincipalPlugin|MockObject $authPlugin */ + $authPlugin = $this->createMock(CustomPrincipalPlugin::class); + $authPlugin->expects(self::once()) + ->method('setCurrentPrincipal') + ->with($this->calendar->getPrincipalURI()); + + /** @var \Sabre\DAVACL\Plugin|MockObject $schedulingPlugin */ + $aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); + $aclPlugin->expects(self::once()) + ->method('getPrincipalByUri') + ->with('mailto:lewis@stardew-tent-living.com'); + + $server = $this->createMock(Server::class); + $server->expects($this->any()) + ->method('getPlugin') + ->willReturnMap([ + ['auth', $authPlugin], + ['acl', $aclPlugin], + ['caldav-schedule', $schedulingPlugin] + ]); + + $invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer']); + $invitationResponseServer->server = $server; + $invitationResponseServer->expects($this->any()) + ->method('getServer') + ->willReturn($server); + $invitationResponseServer->expects(self::once()) + ->method('isExternalAttendee') + ->willReturn(false); + + $calendarImpl = $this->getMockBuilder(CalendarImpl::class) + ->setConstructorArgs([$this->calendar, $this->calendarInfo, $this->backend]) + ->onlyMethods(['getInvitationResponseServer']) + ->getMock(); + $calendarImpl->expects($this->once()) + ->method('getInvitationResponseServer') + ->willReturn($invitationResponseServer); $message = <<createMock(Plugin::class); + $iTipMessage = $this->getITipMessage($message); + $schedulingPlugin->expects(self::once()) + ->method('scheduleLocalDelivery') + ->with($iTipMessage); + $calendarImpl->handleIMipMessage('filename.ics', $message); + } + + public function testHandleImipMessageNoCalendarUri(): void { /** @var CustomPrincipalPlugin|MockObject $authPlugin */ - $authPlugin = $invitationResponseServer->server->getPlugin('auth'); + $authPlugin = $this->createMock(CustomPrincipalPlugin::class); $authPlugin->expects(self::once()) - ->method('setPrincipalUri') + ->method('setCurrentPrincipal') ->with($this->calendar->getPrincipalURI()); + unset($this->calendarInfo['uri']); /** @var Plugin|MockObject $schedulingPlugin */ - $schedulingPlugin = $invitationResponseServer->server->getPlugin('caldav-schedule'); - $schedulingPlugin->expects(self::once()) - ->method('setPathOfCalendarObjectChange') - ->with('fullcalendarname'); - } + $schedulingPlugin = $this->createMock(Plugin::class); - public function testHandleImipMessageNoCalendarUri(): void { - $invitationResponseServer = $this->createConfiguredMock(InvitationResponseServer::class, [ - 'server' => $this->createConfiguredMock(CalDavBackend::class, [ - 'getPlugin' => [ - 'auth' => $this->createMock(CustomPrincipalPlugin::class), - 'schedule' => $this->createMock(Plugin::class) - ] - ]) - ]); + /** @var \Sabre\DAVACL\Plugin|MockObject $schedulingPlugin */ + $aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); + + $server = + $this->createMock(Server::class); + $server->expects($this->any()) + ->method('getPlugin') + ->willReturnMap([ + ['auth', $authPlugin], + ['acl', $aclPlugin], + ['caldav-schedule', $schedulingPlugin] + ]); + + $invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer']); + $invitationResponseServer->server = $server; + $invitationResponseServer->expects($this->any()) + ->method('getServer') + ->willReturn($server); + + $calendarImpl = $this->getMockBuilder(CalendarImpl::class) + ->setConstructorArgs([$this->calendar, $this->calendarInfo, $this->backend]) + ->onlyMethods(['getInvitationResponseServer']) + ->getMock(); + $calendarImpl->expects($this->once()) + ->method('getInvitationResponseServer') + ->willReturn($invitationResponseServer); $message = <<server->getPlugin('auth'); - $authPlugin->expects(self::once()) - ->method('setPrincipalUri') - ->with($this->calendar->getPrincipalURI()); + $this->expectException(CalendarException::class); + $calendarImpl->handleIMipMessage('filename.ics', $message); + } - unset($this->calendarInfo['uri']); - $this->expectException('CalendarException'); - $this->calendarImpl->handleIMipMessage('filename.ics', $message); + private function getITipMessage($calendarData): Message { + $iTipMessage = new Message(); + /** @var VCalendar $vObject */ + $vObject = Reader::read($calendarData); + /** @var VEvent $vEvent */ + $vEvent = $vObject->{'VEVENT'}; + $orgaizer = $vEvent->{'ORGANIZER'}->getValue(); + $attendee = $vEvent->{'ATTENDEE'}->getValue(); + + $iTipMessage->method = $vObject->{'METHOD'}->getValue(); + $iTipMessage->recipient = $orgaizer; + $iTipMessage->sender = $attendee; + $iTipMessage->uid = isset($vEvent->{'UID'}) ? $vEvent->{'UID'}->getValue() : ''; + $iTipMessage->component = 'VEVENT'; + $iTipMessage->sequence = isset($vEvent->{'SEQUENCE'}) ? (int)$vEvent->{'SEQUENCE'}->getValue() : 0; + $iTipMessage->message = $vObject; + return $iTipMessage; } } diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index 248377fc698e9..26e4b85fbb375 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -3,7 +3,9 @@ namespace Test\Encryption; use OC\Encryption\Util; +use OC\Files\Filesystem; use OC\Files\View; +use OC\User\Manager; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Service\GlobalStoragesService; use OCP\Encryption\IEncryptionModule; From e29720f9b2aaf7467acdcfe3c9dde9eceda2e3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 7 Nov 2022 21:20:47 +0100 Subject: [PATCH 3/6] Next attemp on imip tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../tests/unit/CalDAV/CalendarImplTest.php | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index b504e8b124915..92fd760b248fc 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -78,7 +78,7 @@ public function testGetKey() { } public function testGetDisplayname() { - $this->assertEquals($this->calendarImpl->getDisplayName(),'user readable name 123'); + $this->assertEquals($this->calendarImpl->getDisplayName(), 'user readable name 123'); } public function testGetDisplayColor() { @@ -141,17 +141,37 @@ public function testGetPermissionAll() { } public function testHandleImipMessage(): void { + $message = <<createMock(CustomPrincipalPlugin::class); $authPlugin->expects(self::once()) ->method('setCurrentPrincipal') ->with($this->calendar->getPrincipalURI()); - /** @var \Sabre\DAVACL\Plugin|MockObject $schedulingPlugin */ + /** @var \Sabre\DAVACL\Plugin|MockObject $aclPlugin*/ $aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); - $aclPlugin->expects(self::once()) - ->method('getPrincipalByUri') - ->with('mailto:lewis@stardew-tent-living.com'); + + /** @var Plugin|MockObject $schedulingPlugin */ + $schedulingPlugin = $this->createMock(Plugin::class); + $iTipMessage = $this->getITipMessage($message); + $iTipMessage->recipient = "mailto:lewis@stardew-tent-living.com"; + $schedulingPlugin->expects(self::once()) + ->method('scheduleLocalDelivery') + ->with($iTipMessage); $server = $this->createMock(Server::class); $server->expects($this->any()) @@ -162,7 +182,7 @@ public function testHandleImipMessage(): void { ['caldav-schedule', $schedulingPlugin] ]); - $invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer']); + $invitationResponseServer = $this->createPartialMock(InvitationResponseServer::class, ['getServer', 'isExternalAttendee']); $invitationResponseServer->server = $server; $invitationResponseServer->expects($this->any()) ->method('getServer') @@ -179,27 +199,6 @@ public function testHandleImipMessage(): void { ->method('getInvitationResponseServer') ->willReturn($invitationResponseServer); - $message = <<createMock(Plugin::class); - $iTipMessage = $this->getITipMessage($message); - $schedulingPlugin->expects(self::once()) - ->method('scheduleLocalDelivery') - ->with($iTipMessage); - $calendarImpl->handleIMipMessage('filename.ics', $message); } @@ -247,7 +246,7 @@ public function testHandleImipMessageNoCalendarUri(): void { METHOD:REPLY VERSION:2.0 BEGIN:VEVENT -ATTENDEE;PARTSTAT=mailto:lewis@stardew-tent-living.com:ACCEPTED +ATTENDEE;PARTSTAT=ACCEPTED:mailto:lewis@stardew-tent-living.com ORGANIZER:mailto:pierre@generalstore.com UID:aUniqueUid SEQUENCE:2 @@ -261,7 +260,7 @@ public function testHandleImipMessageNoCalendarUri(): void { } private function getITipMessage($calendarData): Message { - $iTipMessage = new Message(); + $iTipMessage = new Message(); /** @var VCalendar $vObject */ $vObject = Reader::read($calendarData); /** @var VEvent $vEvent */ From cb0450b5c4fbe590e7b35284a40d78d96a0251f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 5 Dec 2022 12:01:12 +0100 Subject: [PATCH 4/6] Improve typing on new methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/lib/CalDAV/CalendarImpl.php | 11 +++++------ .../InvitationResponse/InvitationResponseServer.php | 3 +-- .../BackgroundJob/CleanupInvitationTokenJobTest.php | 6 ++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index f9e9c58480832..3fb28a631a724 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -42,7 +42,6 @@ use function Sabre\Uri\split as uriSplit; class CalendarImpl implements ICreateFromString, IHandleImipMessage { - private CalDavBackend $backend; private Calendar $calendar; /** @var array */ @@ -204,25 +203,25 @@ public function handleIMipMessage(string $name, string $calendarData): void { /** @var VEvent $vEvent */ $vEvent = $vObject->{'VEVENT'}; - if($vObject->{'METHOD'} === null) { + if ($vObject->{'METHOD'} === null) { throw new CalendarException('No Method provided for scheduling data. Could not process message'); } - if(!isset($vEvent->{'ORGANIZER'}) || !isset($vEvent->{'ATTENDEE'})) { + if (!isset($vEvent->{'ORGANIZER'}) || !isset($vEvent->{'ATTENDEE'})) { throw new CalendarException('Could not process scheduling data, neccessary data missing from ICAL'); } $organizer = $vEvent->{'ORGANIZER'}->getValue(); $attendee = $vEvent->{'ATTENDEE'}->getValue(); $iTipMessage->method = $vObject->{'METHOD'}->getValue(); - if($iTipMessage->method === 'REPLY') { + if ($iTipMessage->method === 'REPLY') { if ($server->isExternalAttendee($vEvent->{'ATTENDEE'}->getValue())) { $iTipMessage->recipient = $organizer; } else { $iTipMessage->recipient = $attendee; } $iTipMessage->sender = $attendee; - } else if($iTipMessage->method === 'CANCEL') { + } elseif ($iTipMessage->method === 'CANCEL') { $iTipMessage->recipient = $attendee; $iTipMessage->sender = $organizer; } @@ -233,7 +232,7 @@ public function handleIMipMessage(string $name, string $calendarData): void { $schedulingPlugin->scheduleLocalDelivery($iTipMessage); } - public function getInvitationResponseServer() { + public function getInvitationResponseServer(): InvitationResponseServer { return new InvitationResponseServer(false); } } diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php index c2e31f7bdc439..e64c815753b94 100644 --- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php +++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php @@ -39,7 +39,6 @@ use Sabre\VObject\ITip\Message; class InvitationResponseServer { - /** @var \OCA\DAV\Connector\Sabre\Server */ public $server; @@ -131,7 +130,7 @@ public function isExternalAttendee(string $principalUri): bool { return $aclPlugin->getPrincipalByUri($principalUri) === null; } - public function getServer() { + public function getServer(): \OCA\DAV\Connector\Sabre\Server { return $this->server; } } diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php index 295949bdc918d..ee43bae53551c 100644 --- a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php @@ -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; @@ -78,11 +76,11 @@ public function testRun() { [1337, \PDO::PARAM_STR, null, 'namedParameter1337'] ]); - $function = $this->createMock(IQueryFunction::class); + $function = 'fakefunction'; $expr->expects($this->once()) ->method('lt') ->with('expiration', 'namedParameter1337') - ->willReturn((string)$function); + ->willReturn($function); $this->dbConnection->expects($this->once()) ->method('getQueryBuilder') From ee06261b82660b8dfebd7c63941c4ef29a7002e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 5 Dec 2022 16:07:53 +0100 Subject: [PATCH 5/6] Fix codestyle in modified files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/tests/unit/CalDAV/CalendarImplTest.php | 1 - tests/lib/Encryption/UtilTest.php | 3 --- 2 files changed, 4 deletions(-) diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 92fd760b248fc..69e749962dcc8 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -43,7 +43,6 @@ * @group DB */ class CalendarImplTest extends \Test\TestCase { - /** @var CalendarImpl */ private $calendarImpl; diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index 26e4b85fbb375..c2bc4ac55bd46 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -3,9 +3,7 @@ namespace Test\Encryption; use OC\Encryption\Util; -use OC\Files\Filesystem; use OC\Files\View; -use OC\User\Manager; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Service\GlobalStoragesService; use OCP\Encryption\IEncryptionModule; @@ -15,7 +13,6 @@ use Test\TestCase; class UtilTest extends TestCase { - /** * block size will always be 8192 for a PHP stream * @see https://bugs.php.net/bug.php?id=21641 From 8ec7e4301d58eaa8ff1f568e5ace7ac119ae2567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 5 Dec 2022 16:32:01 +0100 Subject: [PATCH 6/6] Use the correct Server class in apps/dav/tests/unit/CalDAV/CalendarImplTest.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/tests/unit/CalDAV/CalendarImplTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 69e749962dcc8..cc0b963634c14 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -31,9 +31,9 @@ use OCA\DAV\CalDAV\CalendarImpl; use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; use OCA\DAV\CalDAV\Schedule\Plugin; +use OCA\DAV\Connector\Sabre\Server; use OCP\Calendar\Exceptions\CalendarException; use PHPUnit\Framework\MockObject\MockObject; -use Sabre\DAV\Server; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VEvent; use Sabre\VObject\ITip\Message;