diff options
Diffstat (limited to 'apps/dav/tests')
21 files changed, 381 insertions, 67 deletions
diff --git a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php index f895deb7fd1..e60efc6fb19 100644 --- a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php +++ b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php @@ -18,7 +18,7 @@ class EnablePluginTest extends TestCase { /** @var \Sabre\DAV\Server|\PHPUnit\Framework\MockObject\MockObject */ protected $server; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; /** @var BirthdayService |\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index bdb318ee32f..6c46a2aed2d 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -14,6 +14,7 @@ use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider; use OCA\DAV\CalDAV\Reminder\NotificationProviderManager; use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException; use OCA\DAV\Capabilities; +use OCP\AppFramework\QueryException; use Test\TestCase; class NotificationProviderManagerTest extends TestCase { @@ -22,7 +23,7 @@ class NotificationProviderManagerTest extends TestCase { private $providerManager; /** - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ protected function setUp(): void { parent::setUp(); @@ -65,7 +66,7 @@ class NotificationProviderManagerTest extends TestCase { } /** - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function testRegisterBadProvider(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 36ce091fc69..94c39e42d16 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -11,7 +11,7 @@ use OCA\DAV\CalDAV\Schedule\IMipPlugin; use OCA\DAV\CalDAV\Schedule\IMipService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Defaults; -use OCP\IConfig; +use OCP\IAppConfig; use OCP\IUser; use OCP\IUserSession; use OCP\Mail\IAttachment; @@ -52,7 +52,7 @@ class IMipPluginTest extends TestCase { /** @var ITimeFactory|MockObject */ private $timeFactory; - /** @var IConfig|MockObject */ + /** @var IAppConfig|MockObject */ private $config; /** @var IUserSession|MockObject */ @@ -105,7 +105,7 @@ class IMipPluginTest extends TestCase { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01 - $this->config = $this->createMock(IConfig::class); + $this->config = $this->createMock(IAppConfig::class); $this->user = $this->createMock(IUser::class); @@ -243,7 +243,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -341,7 +341,7 @@ class IMipPluginTest extends TestCase { $this->service->expects(self::never()) ->method('getAttendeeRsvpOrReqForParticipant'); $this->config->expects(self::never()) - ->method('getAppValue'); + ->method('getValueString'); $this->service->expects(self::never()) ->method('createInvitationToken'); $this->service->expects(self::never()) @@ -447,7 +447,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -578,7 +578,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -633,7 +633,7 @@ class IMipPluginTest extends TestCase { ]; // construct system config mock returns $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); // construct user mock returns @@ -708,6 +708,113 @@ class IMipPluginTest extends TestCase { $this->assertEquals('1.1', $message->getScheduleStatus()); } + public function testMailProviderDisabled(): void { + $message = new Message(); + $message->method = 'REQUEST'; + $newVCalendar = new VCalendar(); + $newVevent = new VEvent($newVCalendar, 'one', array_merge([ + 'UID' => 'uid-1234', + 'SEQUENCE' => 1, + 'SUMMARY' => 'Fellowship meeting without (!) Boromir', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') + ], [])); + $newVevent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $newVevent->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $message->message = $newVCalendar; + $message->sender = 'mailto:gandalf@wiz.ard'; + $message->senderName = 'Mr. Wizard'; + $message->recipient = 'mailto:' . 'frodo@hobb.it'; + // save the old copy in the plugin + $oldVCalendar = new VCalendar(); + $oldVEvent = new VEvent($oldVCalendar, 'one', [ + 'UID' => 'uid-1234', + 'SEQUENCE' => 0, + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') + ]); + $oldVEvent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $oldVEvent->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $oldVEvent->add('ATTENDEE', 'mailto:' . 'boromir@tra.it.or', ['RSVP' => 'TRUE']); + $oldVCalendar->add($oldVEvent); + $data = ['invitee_name' => 'Mr. Wizard', + 'meeting_title' => 'Fellowship meeting without (!) Boromir', + 'attendee_name' => 'frodo@hobb.it' + ]; + $attendees = $newVevent->select('ATTENDEE'); + $atnd = ''; + foreach ($attendees as $attendee) { + if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { + $atnd = $attendee; + } + } + $this->plugin->setVCalendar($oldVCalendar); + $this->service->expects(self::once()) + ->method('getLastOccurrence') + ->willReturn(1496912700); + $this->mailer->expects(self::once()) + ->method('validateMailAddress') + ->with('frodo@hobb.it') + ->willReturn(true); + $this->eventComparisonService->expects(self::once()) + ->method('findModified') + ->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); + $this->service->expects(self::once()) + ->method('getCurrentAttendee') + ->with($message) + ->willReturn($atnd); + $this->service->expects(self::once()) + ->method('isRoomOrResource') + ->with($atnd) + ->willReturn(false); + $this->service->expects(self::once()) + ->method('buildBodyData') + ->with($newVevent, $oldVEvent) + ->willReturn($data); + $this->user->expects(self::any()) + ->method('getUID') + ->willReturn('user1'); + $this->user->expects(self::any()) + ->method('getDisplayName') + ->willReturn('Mr. Wizard'); + $this->userSession->expects(self::any()) + ->method('getUser') + ->willReturn($this->user); + $this->service->expects(self::once()) + ->method('getFrom'); + $this->service->expects(self::once()) + ->method('addSubjectAndHeading') + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true); + $this->service->expects(self::once()) + ->method('addBulletList') + ->with($this->emailTemplate, $newVevent, $data); + $this->service->expects(self::once()) + ->method('getAttendeeRsvpOrReqForParticipant') + ->willReturn(true); + $this->config->expects(self::once()) + ->method('getValueString') + ->with('dav', 'invitation_link_recipients', 'yes') + ->willReturn('yes'); + $this->config->expects(self::once()) + ->method('getValueBool') + ->with('core', 'mail_providers_enabled', true) + ->willReturn(false); + $this->service->expects(self::once()) + ->method('createInvitationToken') + ->with($message, $newVevent, 1496912700) + ->willReturn('token'); + $this->service->expects(self::once()) + ->method('addResponseButtons') + ->with($this->emailTemplate, 'token'); + $this->service->expects(self::once()) + ->method('addMoreOptionsButton') + ->with($this->emailTemplate, 'token'); + $this->mailer->expects(self::once()) + ->method('send') + ->willReturn([]); + $this->plugin->schedule($message); + $this->assertEquals('1.1', $message->getScheduleStatus()); + } + public function testNoOldEvent(): void { $message = new Message(); $message->method = 'REQUEST'; @@ -779,7 +886,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -872,7 +979,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('no'); $this->service->expects(self::never()) @@ -890,4 +997,23 @@ class IMipPluginTest extends TestCase { $this->plugin->schedule($message); $this->assertEquals('1.1', $message->getScheduleStatus()); } + + public function testImipDisabledForEvent(): void { + // construct iTip message with event and attendees + $calendar = new VCalendar(); + $calendar->add('VEVENT', ['UID' => 'uid-1234']); + $event = $calendar->VEVENT; + $event->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $event->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $event->add('X-NC-DISABLE-SCHEDULING', 'true'); + $message = new Message(); + $message->method = 'REQUEST'; + $message->message = $calendar; + $message->sender = 'mailto:gandalf@wiz.ard'; + $message->senderName = 'Mr. Wizard'; + $message->recipient = 'mailto:' . 'frodo@hobb.it'; + + $this->plugin->schedule($message); + $this->assertEquals('1.0;We got the message, but iMip messages are disabled for this event', $message->scheduleStatus); + } } diff --git a/apps/dav/tests/unit/CalDAV/TipBrokerTest.php b/apps/dav/tests/unit/CalDAV/TipBrokerTest.php new file mode 100644 index 00000000000..3a8e240c1d8 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/TipBrokerTest.php @@ -0,0 +1,178 @@ +<?php +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCA\DAV\Tests\unit\CalDAV; + +use OCA\DAV\CalDAV\TipBroker; +use Sabre\VObject\Component\VCalendar; +use Test\TestCase; + +class TipBrokerTest extends TestCase { + + private TipBroker $broker; + private VCalendar $vCalendar1a; + + protected function setUp(): void { + parent::setUp(); + + $this->broker = new TipBroker(); + // construct calendar with a 1 hour event and same start/end time zones + $this->vCalendar1a = new VCalendar(); + /** @var VEvent $vEvent */ + $vEvent = $this->vCalendar1a->add('VEVENT', []); + $vEvent->add('UID', '96a0e6b1-d886-4a55-a60d-152b31401dcc'); + $vEvent->add('DTSTAMP', '20240701T000000Z'); + $vEvent->add('CREATED', '20240701T000000Z'); + $vEvent->add('LAST-MODIFIED', '20240701T000000Z'); + $vEvent->add('SEQUENCE', '1'); + $vEvent->add('STATUS', 'CONFIRMED'); + $vEvent->add('DTSTART', '20240701T080000', ['TZID' => 'America/Toronto']); + $vEvent->add('DTEND', '20240701T090000', ['TZID' => 'America/Toronto']); + $vEvent->add('SUMMARY', 'Test Event'); + $vEvent->add('ORGANIZER', 'mailto:organizer@testing.com', ['CN' => 'Organizer']); + $vEvent->add('ATTENDEE', 'mailto:attendee1@testing.com', [ + 'CN' => 'Attendee One', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + } + + public function testParseEventForOrganizerOnCreate(): void { + + // construct calendar and generate event info for newly created event with one attendee + $calendar = clone $this->vCalendar1a; + $previousEventInfo = [ + 'organizer' => null, + 'significantChangeHash' => '', + 'attendees' => [], + ]; + $currentEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(1, $messages); + $this->assertEquals('REQUEST', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + + } + + public function testParseEventForOrganizerOnModify(): void { + + // construct calendar and generate event info for modified event with one attendee + $calendar = clone $this->vCalendar1a; + $previousEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + $calendar->VEVENT->{'LAST-MODIFIED'}->setValue('20240701T020000Z'); + $calendar->VEVENT->SEQUENCE->setValue(2); + $calendar->VEVENT->SUMMARY->setValue('Test Event Modified'); + $currentEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(1, $messages); + $this->assertEquals('REQUEST', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + + } + + public function testParseEventForOrganizerOnDelete(): void { + + // construct calendar and generate event info for modified event with one attendee + $calendar = clone $this->vCalendar1a; + $previousEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + $currentEventInfo = $previousEventInfo; + $currentEventInfo['attendees'] = []; + ++$currentEventInfo['sequence']; + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(1, $messages); + $this->assertEquals('CANCEL', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + + } + + public function testParseEventForOrganizerOnStatusCancelled(): void { + + // construct calendar and generate event info for modified event with one attendee + $calendar = clone $this->vCalendar1a; + $previousEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + $calendar->VEVENT->{'LAST-MODIFIED'}->setValue('20240701T020000Z'); + $calendar->VEVENT->SEQUENCE->setValue(2); + $calendar->VEVENT->STATUS->setValue('CANCELLED'); + $currentEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(1, $messages); + $this->assertEquals('CANCEL', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + + } + + public function testParseEventForOrganizerOnAddAttendee(): void { + + // construct calendar and generate event info for modified event with two attendees + $calendar = clone $this->vCalendar1a; + $previousEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + $calendar->VEVENT->{'LAST-MODIFIED'}->setValue('20240701T020000Z'); + $calendar->VEVENT->SEQUENCE->setValue(2); + $calendar->VEVENT->add('ATTENDEE', 'mailto:attendee2@testing.com', [ + 'CN' => 'Attendee Two', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + $currentEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(2, $messages); + $this->assertEquals('REQUEST', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + $this->assertEquals('REQUEST', $messages[1]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[1]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[1]->getValue(), $messages[1]->recipient); + + } + + public function testParseEventForOrganizerOnRemoveAttendee(): void { + + // construct calendar and generate event info for modified event with two attendees + $calendar = clone $this->vCalendar1a; + $calendar->VEVENT->add('ATTENDEE', 'mailto:attendee2@testing.com', [ + 'CN' => 'Attendee Two', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + $previousEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + $calendar->VEVENT->{'LAST-MODIFIED'}->setValue('20240701T020000Z'); + $calendar->VEVENT->SEQUENCE->setValue(2); + $calendar->VEVENT->remove('ATTENDEE'); + $calendar->VEVENT->add('ATTENDEE', 'mailto:attendee1@testing.com', [ + 'CN' => 'Attendee One', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + $currentEventInfo = $this->invokePrivate($this->broker, 'parseEventInfo', [$calendar]); + // test iTip generation + $messages = $this->invokePrivate($this->broker, 'parseEventForOrganizer', [$calendar, $currentEventInfo, $previousEventInfo]); + $this->assertCount(2, $messages); + $this->assertEquals('REQUEST', $messages[0]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[0]->sender); + $this->assertEquals($calendar->VEVENT->ATTENDEE[0]->getValue(), $messages[0]->recipient); + $this->assertEquals('CANCEL', $messages[1]->method); + $this->assertEquals($calendar->VEVENT->ORGANIZER->getValue(), $messages[1]->sender); + $this->assertEquals('mailto:attendee2@testing.com', $messages[1]->recipient); + + } + +} diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php index 2640b4d966b..1f5f9882ac4 100644 --- a/apps/dav/tests/unit/Command/ListCalendarsTest.php +++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php @@ -19,7 +19,7 @@ use Test\TestCase; */ class ListCalendarsTest extends TestCase { - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ private $userManager; /** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject $l10n */ diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php index 892b00968f9..9b935ca3cdb 100644 --- a/apps/dav/tests/unit/Command/MoveCalendarTest.php +++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php @@ -24,10 +24,10 @@ use Test\TestCase; * @package OCA\DAV\Tests\Command */ class MoveCalendarTest extends TestCase { - /** @var \OCP\IUserManager|MockObject $userManager */ + /** @var IUserManager|MockObject $userManager */ private $userManager; - /** @var \OCP\IGroupManager|MockObject $groupManager */ + /** @var IGroupManager|MockObject $groupManager */ private $groupManager; /** @var \OCP\Share\IManager|MockObject $shareManager */ diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index 6996022b607..e5a68e5a726 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -18,7 +18,7 @@ use Psr\Log\LoggerInterface; class EntityCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php index 15b8073481c..e5706099270 100644 --- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php @@ -18,7 +18,7 @@ class EntityTypeCollectionTest extends \Test\TestCase { /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index 8f58e5c3c5f..5d9e828f687 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -20,19 +20,19 @@ use Psr\Log\LoggerInterface; class RootCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var RootCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ protected $userSession; /** @var IEventDispatcher */ protected $dispatcher; - /** @var \OCP\IUser|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */ protected $user; protected function setUp(): void { diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index 3f134745f86..72d5e7198a3 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -40,7 +40,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { private $plugin; /** - * @var \OCP\IUser + * @var IUser */ private $user; diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index d659b01d039..7510340aa57 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -23,14 +23,11 @@ use OCP\Files\StorageNotAvailableException; use Test\Traits\UserTrait; class TestViewDirectory extends View { - private $updatables; - private $deletables; - private $canRename; - - public function __construct($updatables, $deletables, $canRename = true) { - $this->updatables = $updatables; - $this->deletables = $deletables; - $this->canRename = $canRename; + public function __construct( + private $updatables, + private $deletables, + private $canRename = true, + ) { } public function isUpdatable($path) { @@ -61,9 +58,9 @@ class TestViewDirectory extends View { class DirectoryTest extends \Test\TestCase { use UserTrait; - /** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */ + /** @var View|\PHPUnit\Framework\MockObject\MockObject */ private $view; - /** @var \OC\Files\FileInfo | \PHPUnit\Framework\MockObject\MockObject */ + /** @var FileInfo|\PHPUnit\Framework\MockObject\MockObject */ private $info; protected function setUp(): void { diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php index cf1ea4c6bae..df48cd61114 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php @@ -13,24 +13,15 @@ use Sabre\HTTP\ResponseInterface; class Auth implements BackendInterface { /** - * @var string - */ - private $user; - - /** - * @var string - */ - private $password; - - /** * Auth constructor. * * @param string $user * @param string $password */ - public function __construct($user, $password) { - $this->user = $user; - $this->password = $password; + public function __construct( + private $user, + private $password, + ) { } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 67c2aa61430..4085bc93c78 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -64,7 +64,7 @@ abstract class RequestTestCase extends TestCase { } /** - * @param \OC\Files\View $view the view to run the webdav server against + * @param View $view the view to run the webdav server against * @param string $user * @param string $password * @param string $method diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php index f7bcdd930ca..f12c93468ff 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php @@ -12,11 +12,6 @@ use Sabre\HTTP\Response; class Sapi { /** - * @var \Sabre\HTTP\Request - */ - private $request; - - /** * @var \Sabre\HTTP\Response */ private $response; @@ -31,8 +26,9 @@ class Sapi { return $this->request; } - public function __construct(Request $request) { - $this->request = $request; + public function __construct( + private Request $request, + ) { } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 125fe3959bb..97d3ba79046 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -38,7 +38,7 @@ class SharesPluginTest extends \Test\TestCase { private $shareManager; /** - * @var \OCP\Files\Folder + * @var Folder */ private $userFolder; diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 59fd1e56963..bdab8135b1c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -33,12 +33,12 @@ class TagsPluginTest extends \Test\TestCase { private $tree; /** - * @var \OCP\ITagManager + * @var ITagManager */ private $tagManager; /** - * @var \OCP\ITags + * @var ITags */ private $tagger; diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php index f6fe8b1c116..aaa3d8c147e 100644 --- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php +++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php @@ -55,6 +55,10 @@ class FileSearchBackendTest extends TestCase { private $davFolder; protected function setUp(): void { + if (PHP_VERSION_ID >= 80400) { + $this->markTestSkipped('SearchDAV is not yet PHP 8.4 compatible'); + } + parent::setUp(); $this->user = $this->createMock(IUser::class); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php index 7ad1d34d94f..b84eb90b7bf 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -12,6 +12,7 @@ use OCA\DAV\SystemTag\SystemTagNode; use OCP\IUser; use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagAlreadyExistsException; use OCP\SystemTag\TagNotFoundException; use Sabre\DAV\Exception\Forbidden; @@ -19,12 +20,17 @@ use Sabre\DAV\Exception\Forbidden; class SystemTagNodeTest extends \Test\TestCase { /** - * @var \OCP\SystemTag\ISystemTagManager|\PHPUnit\Framework\MockObject\MockObject + * @var ISystemTagManager|\PHPUnit\Framework\MockObject\MockObject */ private $tagManager; /** - * @var \OCP\IUser + * @var ISystemTagObjectMapper|\PHPUnit\Framework\MockObject\MockObject + */ + private $tagMapper; + + /** + * @var IUser */ private $user; @@ -33,6 +39,8 @@ class SystemTagNodeTest extends \Test\TestCase { $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); + $this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class) + ->getMock(); $this->user = $this->getMockBuilder(IUser::class) ->getMock(); } @@ -45,7 +53,8 @@ class SystemTagNodeTest extends \Test\TestCase { $tag, $this->user, $isAdmin, - $this->tagManager + $this->tagManager, + $this->tagMapper, ); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index 91dab4ecf11..e1517eec425 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -42,7 +42,7 @@ class SystemTagPluginTest extends \Test\TestCase { private $tree; /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index 2ffbc1cf01f..b26171650a2 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -13,17 +13,19 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; +use PHPUnit\Framework\MockObject\MockObject; class SystemTagsByIdCollectionTest extends \Test\TestCase { /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; /** - * @var \OCP\IUser + * @var IUser */ private $user; @@ -40,21 +42,31 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { $this->user->expects($this->any()) ->method('getUID') ->willReturn('testuser'); + + /** @var IUserSession|MockObject */ $userSession = $this->getMockBuilder(IUserSession::class) ->getMock(); $userSession->expects($this->any()) ->method('getUser') ->willReturn($this->user); + + /** @var IGroupManager|MockObject */ $groupManager = $this->getMockBuilder(IGroupManager::class) ->getMock(); $groupManager->expects($this->any()) ->method('isAdmin') ->with('testuser') ->willReturn($isAdmin); + + /** @var ISystemTagObjectMapper|MockObject */ + $tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class) + ->getMock(); + return new SystemTagsByIdCollection( $this->tagManager, $userSession, - $groupManager + $groupManager, + $tagMapper, ); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index 62f6963e202..ba9304d33fc 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -24,17 +24,17 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { private $node; /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; /** - * @var \OCP\SystemTag\ISystemTagObjectMapper + * @var ISystemTagObjectMapper */ private $tagMapper; /** - * @var \OCP\Files\Folder + * @var Folder */ private $userFolder; |