|
|
|
@ -24,31 +24,31 @@ namespace OCA\DAV\Tests\unit\CalDAV\Status; |
|
|
|
|
|
|
|
|
|
use OC\Calendar\CalendarQuery; |
|
|
|
|
use OCA\DAV\CalDAV\CalendarImpl; |
|
|
|
|
use OCA\DAV\CalDAV\FreeBusy\FreeBusyGenerator; |
|
|
|
|
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; |
|
|
|
|
use OCA\DAV\CalDAV\Schedule\Plugin; |
|
|
|
|
use OCA\DAV\CalDAV\Status\StatusService; |
|
|
|
|
use OCA\DAV\Connector\Sabre\Server; |
|
|
|
|
use OCA\UserStatus\Db\UserStatus; |
|
|
|
|
use OCA\UserStatus\Service\StatusService as UserStatusService; |
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException; |
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
|
|
|
|
use OCP\Calendar\IManager; |
|
|
|
|
use OCP\IL10N; |
|
|
|
|
use OCP\ICache; |
|
|
|
|
use OCP\ICacheFactory; |
|
|
|
|
use OCP\IUser; |
|
|
|
|
use OCP\IUserManager; |
|
|
|
|
use OCP\User\IAvailabilityCoordinator; |
|
|
|
|
use OCP\User\IOutOfOfficeData; |
|
|
|
|
use OCP\UserStatus\IUserStatus; |
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
|
|
|
use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp; |
|
|
|
|
use Sabre\DAV\Exception\NotAuthenticated; |
|
|
|
|
use Sabre\DAV\Xml\Property\LocalHref; |
|
|
|
|
use Sabre\DAVACL\Exception\NeedPrivileges; |
|
|
|
|
use Sabre\VObject\Component\VCalendar; |
|
|
|
|
use Sabre\VObject\Component\VTimeZone; |
|
|
|
|
use Sabre\VObject\Reader; |
|
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
use Test\TestCase; |
|
|
|
|
|
|
|
|
|
class StatusServiceTest extends TestCase { |
|
|
|
|
private ITimeFactory|MockObject $timeFactory; |
|
|
|
|
private IManager|MockObject $calendarManager; |
|
|
|
|
private InvitationResponseServer|MockObject $server; |
|
|
|
|
private IL10N|MockObject $l10n; |
|
|
|
|
private FreeBusyGenerator|MockObject $generator; |
|
|
|
|
private IUserManager|MockObject $userManager; |
|
|
|
|
private UserStatusService|MockObject $userStatusService; |
|
|
|
|
private IAvailabilityCoordinator|MockObject $availabilityCoordinator; |
|
|
|
|
private ICacheFactory|MockObject $cacheFactory; |
|
|
|
|
private LoggerInterface|MockObject $logger; |
|
|
|
|
private StatusService $service; |
|
|
|
|
|
|
|
|
|
protected function setUp(): void { |
|
|
|
@ -56,644 +56,360 @@ class StatusServiceTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->timeFactory = $this->createMock(ITimeFactory::class); |
|
|
|
|
$this->calendarManager = $this->createMock(IManager::class); |
|
|
|
|
$this->server = $this->createMock(InvitationResponseServer::class); |
|
|
|
|
$this->l10n = $this->createMock(IL10N::class); |
|
|
|
|
$this->generator = $this->createMock(FreeBusyGenerator::class); |
|
|
|
|
$this->userManager = $this->createMock(IUserManager::class); |
|
|
|
|
$this->userStatusService = $this->createMock(UserStatusService::class); |
|
|
|
|
$this->availabilityCoordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
|
|
|
$this->cacheFactory = $this->createMock(ICacheFactory::class); |
|
|
|
|
$this->logger = $this->createMock(LoggerInterface::class); |
|
|
|
|
$this->cache = $this->createMock(ICache::class); |
|
|
|
|
$this->cacheFactory->expects(self::once()) |
|
|
|
|
->method('createLocal') |
|
|
|
|
->with('CalendarStatusService') |
|
|
|
|
->willReturn($this->cache); |
|
|
|
|
|
|
|
|
|
$this->service = new StatusService($this->timeFactory, |
|
|
|
|
$this->calendarManager, |
|
|
|
|
$this->server, |
|
|
|
|
$this->l10n, |
|
|
|
|
$this->generator); |
|
|
|
|
$this->userManager, |
|
|
|
|
$this->userStatusService, |
|
|
|
|
$this->availabilityCoordinator, |
|
|
|
|
$this->cacheFactory, |
|
|
|
|
$this->logger, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNoEmail(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => null, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
public function testNoUser(): void { |
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->server->expects(self::never()) |
|
|
|
|
->method('getServer'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('now'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('getCurrentOutOfOfficeData'); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->logger->expects(self::never()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->cache->expects(self::never()) |
|
|
|
|
->method('get'); |
|
|
|
|
$this->cache->expects(self::never()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('getCalendarsForPrincipal'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('findByUserId'); |
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNoAcl(): void { |
|
|
|
|
public function testOOOInEffect(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn([]); |
|
|
|
|
$aclPlugin->expects(self::never()) |
|
|
|
|
->method('checkPrivileges'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('now'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn($this->createMock(IOutOfOfficeData::class)); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('isInEffect') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->cache->expects(self::never()) |
|
|
|
|
->method('get'); |
|
|
|
|
$this->cache->expects(self::never()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('getCalendarsForPrincipal'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('findByUserId'); |
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNoInbox(): void { |
|
|
|
|
public function testNoCalendars(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->willReturn([]); |
|
|
|
|
$aclPlugin->expects(self::never()) |
|
|
|
|
->method('checkPrivileges'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('now'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('getCalendarsForPrincipal'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNoPrivilegesAcl(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$principal = 'principals/users/admin'; |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willThrowException(new NeedPrivileges($principal, ['{DAV:}all'])); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('now'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('getCalendarsForPrincipal'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('findByUserId'); |
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNotAuthenticated(): void { |
|
|
|
|
public function testNoCalendarEvents(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willThrowException(new NotAuthenticated()); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('now'); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('getCalendarsForPrincipal'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->willReturn([$this->createMock(CalendarImpl::class)]); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('newQuery') |
|
|
|
|
->willReturn(new CalendarQuery('admin')); |
|
|
|
|
$this->timeFactory->expects(self::exactly(2)) |
|
|
|
|
->method('getDateTime') |
|
|
|
|
->willReturn(new \DateTime()); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('searchForPrincipal') |
|
|
|
|
->willReturn([]); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('findByUserId'); |
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testNoCalendars(): void { |
|
|
|
|
public function testCalendarEvent(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
$now = new \DateTimeImmutable('1970-1-1', new \DateTimeZone('UTC')); |
|
|
|
|
$principal = 'principals/users/admin'; |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->method('now') |
|
|
|
|
->willReturn($now); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn([]); |
|
|
|
|
$this->timeFactory->expects(self::never()) |
|
|
|
|
->method('getDateTime'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('newQuery'); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
->willReturn([$this->createMock(CalendarImpl::class)]); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('newQuery') |
|
|
|
|
->willReturn(new CalendarQuery('admin')); |
|
|
|
|
$this->timeFactory->expects(self::exactly(2)) |
|
|
|
|
->method('getDateTime') |
|
|
|
|
->willReturn(new \DateTime()); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('findByUserId') |
|
|
|
|
->willThrowException(new DoesNotExistException('')); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('searchForPrincipal') |
|
|
|
|
->willReturn([['objects' => [[]]]]); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testEmptyAvailabilityAndNoSearchCalendars(): void { |
|
|
|
|
public function testCallStatus(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$now = new \DateTimeImmutable('1970-1-1', new \DateTimeZone('UTC')); |
|
|
|
|
$inTenMinutes = new \DateTime('1970-1-1 01:00'); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
$principal = 'principals/users/admin'; |
|
|
|
|
$calendar = $this->createMock(CalendarImpl::class); |
|
|
|
|
$query = $this->createMock(CalendarQuery::class); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with([ '{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->method('now') |
|
|
|
|
->willReturn($now); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn([$calendar]); |
|
|
|
|
->willReturn([$this->createMock(CalendarImpl::class)]); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('newQuery') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn($query); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getSchedulingTransparency') |
|
|
|
|
->willReturn(new ScheduleCalendarTransp('transparent')); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->willReturn(new CalendarQuery('admin')); |
|
|
|
|
$this->timeFactory->expects(self::exactly(2)) |
|
|
|
|
->method('getDateTime') |
|
|
|
|
->with('+10 minutes') |
|
|
|
|
->willReturn($inTenMinutes); |
|
|
|
|
$this->calendarManager->expects(self::never()) |
|
|
|
|
->method('searchForPrincipal'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
->willReturn(new \DateTime()); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('searchForPrincipal') |
|
|
|
|
->willReturn([['objects' => [[]]]]); |
|
|
|
|
$userStatus = new UserStatus(); |
|
|
|
|
$userStatus->setMessageId(IUserStatus::MESSAGE_CALL); |
|
|
|
|
$userStatus->setStatusTimestamp(123456); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('findByUserId') |
|
|
|
|
->willReturn($userStatus); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testEmptyAvailabilityAndSearchCalendarsNoResults(): void { |
|
|
|
|
public function testInvisibleStatus(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$availability = ''; |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
$now = new \DateTimeImmutable('1970-1-1 00:00', new \DateTimeZone('UTC')); |
|
|
|
|
$inTenMinutes = new \DateTime('1970-1-1 01:00'); |
|
|
|
|
$immutableInTenMinutes = \DateTimeImmutable::createFromMutable($inTenMinutes); |
|
|
|
|
$principal = 'principals/users/admin'; |
|
|
|
|
$query = $this->createMock(CalendarQuery::class); |
|
|
|
|
$timezone = new \DateTimeZone('UTC'); |
|
|
|
|
$timezoneObj = $this->createMock(VTimeZone::class); |
|
|
|
|
$calendar = $this->createMock(CalendarImpl::class); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with(['{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->method('now') |
|
|
|
|
->willReturn($now); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn([$calendar]); |
|
|
|
|
->willReturn([$this->createMock(CalendarImpl::class)]); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('newQuery') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn($query); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getSchedulingTransparency') |
|
|
|
|
->willReturn(new ScheduleCalendarTransp('opaque')); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getSchedulingTimezone') |
|
|
|
|
->willReturn($timezoneObj); |
|
|
|
|
$timezoneObj->expects(self::once()) |
|
|
|
|
->method('getTimeZone') |
|
|
|
|
->willReturn($timezone); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getUri'); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('addSearchCalendar'); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('getCalendarUris') |
|
|
|
|
->willReturn([$calendar]); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->willReturn(new CalendarQuery('admin')); |
|
|
|
|
$this->timeFactory->expects(self::exactly(2)) |
|
|
|
|
->method('getDateTime') |
|
|
|
|
->with('+10 minutes') |
|
|
|
|
->willReturn($inTenMinutes); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('setTimerangeStart') |
|
|
|
|
->with($now); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('setTimerangeEnd') |
|
|
|
|
->with($immutableInTenMinutes); |
|
|
|
|
->willReturn(new \DateTime()); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('searchForPrincipal') |
|
|
|
|
->with($query) |
|
|
|
|
->willReturn([]); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
->willReturn([['objects' => [[]]]]); |
|
|
|
|
$userStatus = new UserStatus(); |
|
|
|
|
$userStatus->setStatus(IUserStatus::INVISIBLE); |
|
|
|
|
$userStatus->setStatusTimestamp(123456); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('findByUserId') |
|
|
|
|
->willReturn($userStatus); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testSearchCalendarsNoResults(): void { |
|
|
|
|
public function testDNDStatus(): void { |
|
|
|
|
$user = $this->createConfiguredMock(IUser::class, [ |
|
|
|
|
'getUID' => 'admin', |
|
|
|
|
'getEMailAddress' => 'test@test.com', |
|
|
|
|
]); |
|
|
|
|
$server = $this->createMock(Server::class); |
|
|
|
|
$schedulingPlugin = $this->createMock(Plugin::class); |
|
|
|
|
$aclPlugin = $this->createMock(\Sabre\DAVACL\Plugin::class); |
|
|
|
|
$calendarHome = $this->createMock(LocalHref::class); |
|
|
|
|
$acl = [[200 => ['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL' => $calendarHome]]]; |
|
|
|
|
$now = new \DateTimeImmutable('1970-1-1 00:00', new \DateTimeZone('UTC')); |
|
|
|
|
$inTenMinutes = new \DateTime('1970-1-1 01:00'); |
|
|
|
|
$immutableInTenMinutes = \DateTimeImmutable::createFromMutable($inTenMinutes); |
|
|
|
|
$principal = 'principals/users/admin'; |
|
|
|
|
$query = $this->createMock(CalendarQuery::class); |
|
|
|
|
$timezone = new \DateTimeZone('UTC'); |
|
|
|
|
$timezoneObj = $this->createMock(VTimeZone::class); |
|
|
|
|
$calendar = $this->createMock(CalendarImpl::class); |
|
|
|
|
$vCalendar = $this->createMock(VCalendar::class); |
|
|
|
|
$result = Reader::read('BEGIN:VCALENDAR |
|
|
|
|
VERSION:2.0 |
|
|
|
|
PRODID:-//Sabre//Sabre VObject 4.5.3//EN |
|
|
|
|
CALSCALE:GREGORIAN |
|
|
|
|
METHOD:REQUEST |
|
|
|
|
END:VCALENDAR'); |
|
|
|
|
|
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getUID') |
|
|
|
|
->willReturn('admin'); |
|
|
|
|
$user->expects(self::once()) |
|
|
|
|
->method('getEMailAddress') |
|
|
|
|
->willReturn('test@test.com'); |
|
|
|
|
$this->server->expects(self::once()) |
|
|
|
|
->method('getServer') |
|
|
|
|
->willReturn($server); |
|
|
|
|
$server->expects(self::exactly(2)) |
|
|
|
|
->method('getPlugin') |
|
|
|
|
->withConsecutive( |
|
|
|
|
['caldav-schedule'], |
|
|
|
|
['acl'], |
|
|
|
|
)->willReturnOnConsecutiveCalls($schedulingPlugin, $aclPlugin); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('principalSearch') |
|
|
|
|
->with(['{http://sabredav.org/ns}email-address' => 'test@test.com']) |
|
|
|
|
->willReturn($acl); |
|
|
|
|
$calendarHome->expects(self::once()) |
|
|
|
|
->method('getHref') |
|
|
|
|
->willReturn('calendars/admin/inbox/'); |
|
|
|
|
$aclPlugin->expects(self::once()) |
|
|
|
|
->method('checkPrivileges') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->method('now') |
|
|
|
|
->willReturn($now); |
|
|
|
|
|
|
|
|
|
$this->userManager->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($user); |
|
|
|
|
$this->availabilityCoordinator->expects(self::once()) |
|
|
|
|
->method('getCurrentOutOfOfficeData') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->availabilityCoordinator->expects(self::never()) |
|
|
|
|
->method('isInEffect'); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn(null); |
|
|
|
|
$this->cache->expects(self::once()) |
|
|
|
|
->method('set'); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('getCalendarsForPrincipal') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn([$calendar]); |
|
|
|
|
->willReturn([$this->createMock(CalendarImpl::class)]); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('newQuery') |
|
|
|
|
->with($principal) |
|
|
|
|
->willReturn($query); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getSchedulingTransparency') |
|
|
|
|
->willReturn(new ScheduleCalendarTransp('opaque')); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getSchedulingTimezone') |
|
|
|
|
->willReturn($timezoneObj); |
|
|
|
|
$timezoneObj->expects(self::once()) |
|
|
|
|
->method('getTimeZone') |
|
|
|
|
->willReturn($timezone); |
|
|
|
|
$calendar->expects(self::once()) |
|
|
|
|
->method('getUri'); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('addSearchCalendar'); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('getCalendarUris') |
|
|
|
|
->willReturn([$calendar]); |
|
|
|
|
$this->timeFactory->expects(self::once()) |
|
|
|
|
->willReturn(new CalendarQuery('admin')); |
|
|
|
|
$this->timeFactory->expects(self::exactly(2)) |
|
|
|
|
->method('getDateTime') |
|
|
|
|
->with('+10 minutes') |
|
|
|
|
->willReturn($inTenMinutes); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('setTimerangeStart') |
|
|
|
|
->with($now); |
|
|
|
|
$query->expects(self::once()) |
|
|
|
|
->method('setTimerangeEnd') |
|
|
|
|
->with($immutableInTenMinutes); |
|
|
|
|
->willReturn(new \DateTime()); |
|
|
|
|
$this->calendarManager->expects(self::once()) |
|
|
|
|
->method('searchForPrincipal') |
|
|
|
|
->with($query) |
|
|
|
|
->willReturn([]); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getVCalendar'); |
|
|
|
|
$vCalendar->expects(self::never()) |
|
|
|
|
->method('add'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setObjects'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeRange'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('setTimeZone'); |
|
|
|
|
$this->generator->expects(self::never()) |
|
|
|
|
->method('getResult'); |
|
|
|
|
|
|
|
|
|
$status = $this->service->processCalendarAvailability($user); |
|
|
|
|
$this->assertNull($status); |
|
|
|
|
->willReturn([['objects' => [[]]]]); |
|
|
|
|
$userStatus = new UserStatus(); |
|
|
|
|
$userStatus->setStatus(IUserStatus::DND); |
|
|
|
|
$userStatus->setStatusTimestamp(123456); |
|
|
|
|
$this->userStatusService->expects(self::once()) |
|
|
|
|
->method('findByUserId') |
|
|
|
|
->willReturn($userStatus); |
|
|
|
|
$this->logger->expects(self::once()) |
|
|
|
|
->method('debug'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('revertUserStatus'); |
|
|
|
|
$this->userStatusService->expects(self::never()) |
|
|
|
|
->method('setUserStatus'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->service->processCalendarStatus('admin'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|