Completed
Push — master ( ca4819...0ca6f7 )
by Joas
28:28 queued 14s
created
apps/dav/tests/unit/Avatars/AvatarNodeTest.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class AvatarNodeTest extends TestCase {
17
-	public function testGetName(): void {
18
-		/** @var IAvatar&MockObject $a */
19
-		$a = $this->createMock(IAvatar::class);
20
-		$n = new AvatarNode(1024, 'png', $a);
21
-		$this->assertEquals('1024.png', $n->getName());
22
-	}
17
+    public function testGetName(): void {
18
+        /** @var IAvatar&MockObject $a */
19
+        $a = $this->createMock(IAvatar::class);
20
+        $n = new AvatarNode(1024, 'png', $a);
21
+        $this->assertEquals('1024.png', $n->getName());
22
+    }
23 23
 
24
-	public function testGetContentType(): void {
25
-		/** @var IAvatar&MockObject $a */
26
-		$a = $this->createMock(IAvatar::class);
27
-		$n = new AvatarNode(1024, 'png', $a);
28
-		$this->assertEquals('image/png', $n->getContentType());
24
+    public function testGetContentType(): void {
25
+        /** @var IAvatar&MockObject $a */
26
+        $a = $this->createMock(IAvatar::class);
27
+        $n = new AvatarNode(1024, 'png', $a);
28
+        $this->assertEquals('image/png', $n->getContentType());
29 29
 
30
-		$n = new AvatarNode(1024, 'jpeg', $a);
31
-		$this->assertEquals('image/jpeg', $n->getContentType());
32
-	}
30
+        $n = new AvatarNode(1024, 'jpeg', $a);
31
+        $this->assertEquals('image/jpeg', $n->getContentType());
32
+    }
33 33
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/Avatars/AvatarHomeTest.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -18,88 +18,88 @@
 block discarded – undo
18 18
 use Test\TestCase;
19 19
 
20 20
 class AvatarHomeTest extends TestCase {
21
-	private AvatarHome $home;
22
-	private IAvatarManager&MockObject $avatarManager;
23
-
24
-	protected function setUp(): void {
25
-		parent::setUp();
26
-		$this->avatarManager = $this->createMock(IAvatarManager::class);
27
-		$this->home = new AvatarHome(['uri' => 'principals/users/admin'], $this->avatarManager);
28
-	}
29
-
30
-	/**
31
-	 * @dataProvider providesForbiddenMethods
32
-	 */
33
-	public function testForbiddenMethods($method): void {
34
-		$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
35
-
36
-		$this->home->$method('');
37
-	}
38
-
39
-	public static function providesForbiddenMethods(): array {
40
-		return [
41
-			['createFile'],
42
-			['createDirectory'],
43
-			['delete'],
44
-			['setName']
45
-		];
46
-	}
47
-
48
-	public function testGetName(): void {
49
-		$n = $this->home->getName();
50
-		self::assertEquals('admin', $n);
51
-	}
52
-
53
-	public static function providesTestGetChild(): array {
54
-		return [
55
-			[MethodNotAllowed::class, false, ''],
56
-			[MethodNotAllowed::class, false, 'bla.foo'],
57
-			[MethodNotAllowed::class, false, 'bla.png'],
58
-			[NotFound::class, false, '512.png'],
59
-			[null, true, '512.png'],
60
-		];
61
-	}
62
-
63
-	/**
64
-	 * @dataProvider providesTestGetChild
65
-	 */
66
-	public function testGetChild(?string $expectedException, bool $hasAvatar, string $path): void {
67
-		if ($expectedException !== null) {
68
-			$this->expectException($expectedException);
69
-		}
70
-
71
-		$avatar = $this->createMock(IAvatar::class);
72
-		$avatar->method('exists')->willReturn($hasAvatar);
73
-
74
-		$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
75
-		$avatarNode = $this->home->getChild($path);
76
-		$this->assertInstanceOf(AvatarNode::class, $avatarNode);
77
-	}
78
-
79
-	public function testGetChildren(): void {
80
-		$avatarNodes = $this->home->getChildren();
81
-		self::assertEquals(0, count($avatarNodes));
82
-
83
-		$avatar = $this->createMock(IAvatar::class);
84
-		$avatar->expects($this->once())->method('exists')->willReturn(true);
85
-		$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
86
-		$avatarNodes = $this->home->getChildren();
87
-		self::assertEquals(1, count($avatarNodes));
88
-	}
89
-
90
-	/**
91
-	 * @dataProvider providesTestGetChild
92
-	 */
93
-	public function testChildExists(?string $expectedException, bool $hasAvatar, string $path): void {
94
-		$avatar = $this->createMock(IAvatar::class);
95
-		$avatar->method('exists')->willReturn($hasAvatar);
96
-
97
-		$this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
98
-		$childExists = $this->home->childExists($path);
99
-		$this->assertEquals($hasAvatar, $childExists);
100
-	}
101
-
102
-	public function testGetLastModified(): void {
103
-		self::assertNull($this->home->getLastModified());
104
-	}
21
+    private AvatarHome $home;
22
+    private IAvatarManager&MockObject $avatarManager;
23
+
24
+    protected function setUp(): void {
25
+        parent::setUp();
26
+        $this->avatarManager = $this->createMock(IAvatarManager::class);
27
+        $this->home = new AvatarHome(['uri' => 'principals/users/admin'], $this->avatarManager);
28
+    }
29
+
30
+    /**
31
+     * @dataProvider providesForbiddenMethods
32
+     */
33
+    public function testForbiddenMethods($method): void {
34
+        $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
35
+
36
+        $this->home->$method('');
37
+    }
38
+
39
+    public static function providesForbiddenMethods(): array {
40
+        return [
41
+            ['createFile'],
42
+            ['createDirectory'],
43
+            ['delete'],
44
+            ['setName']
45
+        ];
46
+    }
47
+
48
+    public function testGetName(): void {
49
+        $n = $this->home->getName();
50
+        self::assertEquals('admin', $n);
51
+    }
52
+
53
+    public static function providesTestGetChild(): array {
54
+        return [
55
+            [MethodNotAllowed::class, false, ''],
56
+            [MethodNotAllowed::class, false, 'bla.foo'],
57
+            [MethodNotAllowed::class, false, 'bla.png'],
58
+            [NotFound::class, false, '512.png'],
59
+            [null, true, '512.png'],
60
+        ];
61
+    }
62
+
63
+    /**
64
+     * @dataProvider providesTestGetChild
65
+     */
66
+    public function testGetChild(?string $expectedException, bool $hasAvatar, string $path): void {
67
+        if ($expectedException !== null) {
68
+            $this->expectException($expectedException);
69
+        }
70
+
71
+        $avatar = $this->createMock(IAvatar::class);
72
+        $avatar->method('exists')->willReturn($hasAvatar);
73
+
74
+        $this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
75
+        $avatarNode = $this->home->getChild($path);
76
+        $this->assertInstanceOf(AvatarNode::class, $avatarNode);
77
+    }
78
+
79
+    public function testGetChildren(): void {
80
+        $avatarNodes = $this->home->getChildren();
81
+        self::assertEquals(0, count($avatarNodes));
82
+
83
+        $avatar = $this->createMock(IAvatar::class);
84
+        $avatar->expects($this->once())->method('exists')->willReturn(true);
85
+        $this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
86
+        $avatarNodes = $this->home->getChildren();
87
+        self::assertEquals(1, count($avatarNodes));
88
+    }
89
+
90
+    /**
91
+     * @dataProvider providesTestGetChild
92
+     */
93
+    public function testChildExists(?string $expectedException, bool $hasAvatar, string $path): void {
94
+        $avatar = $this->createMock(IAvatar::class);
95
+        $avatar->method('exists')->willReturn($hasAvatar);
96
+
97
+        $this->avatarManager->expects($this->any())->method('getAvatar')->with('admin')->willReturn($avatar);
98
+        $childExists = $this->home->childExists($path);
99
+        $this->assertEquals($hasAvatar, $childExists);
100
+    }
101
+
102
+    public function testGetLastModified(): void {
103
+        self::assertNull($this->home->getLastModified());
104
+    }
105 105
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/PublicCalendarTest.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -16,55 +16,55 @@  discard block
 block discarded – undo
16 16
 
17 17
 class PublicCalendarTest extends CalendarTest {
18 18
 
19
-	/**
20
-	 * @dataProvider providesConfidentialClassificationData
21
-	 */
22
-	public function testPrivateClassification(int $expectedChildren, bool $isShared): void {
23
-		$calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC];
24
-		$calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL];
25
-		$calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE];
26
-
27
-		/** @var CalDavBackend&MockObject $backend */
28
-		$backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
29
-		$backend->expects($this->any())->method('getCalendarObjects')->willReturn([
30
-			$calObject0, $calObject1, $calObject2
31
-		]);
32
-		$backend->expects($this->any())->method('getMultipleCalendarObjects')
33
-			->with(666, ['event-0', 'event-1', 'event-2'])
34
-			->willReturn([
35
-				$calObject0, $calObject1, $calObject2
36
-			]);
37
-		$backend->expects($this->any())->method('getCalendarObject')
38
-			->willReturn($calObject2)->with(666, 'event-2');
39
-		$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
40
-
41
-		$calendarInfo = [
42
-			'{http://owncloud.org/ns}owner-principal' => 'user2',
43
-			'principaluri' => 'user2',
44
-			'id' => 666,
45
-			'uri' => 'cal',
46
-		];
47
-		/** @var IConfig&MockObject $config */
48
-		$config = $this->createMock(IConfig::class);
49
-		/** @var LoggerInterface&MockObject $logger */
50
-		$logger = $this->createMock(LoggerInterface::class);
51
-		$c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger);
52
-		$children = $c->getChildren();
53
-		$this->assertEquals(2, count($children));
54
-		$children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']);
55
-		$this->assertEquals(2, count($children));
56
-
57
-		$this->assertFalse($c->childExists('event-2'));
58
-	}
59
-
60
-	/**
61
-	 * @dataProvider providesConfidentialClassificationData
62
-	 */
63
-	public function testConfidentialClassification(int $expectedChildren, bool $isShared): void {
64
-		$start = '20160609';
65
-		$end = '20160610';
66
-
67
-		$calData = <<<EOD
19
+    /**
20
+     * @dataProvider providesConfidentialClassificationData
21
+     */
22
+    public function testPrivateClassification(int $expectedChildren, bool $isShared): void {
23
+        $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC];
24
+        $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL];
25
+        $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE];
26
+
27
+        /** @var CalDavBackend&MockObject $backend */
28
+        $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
29
+        $backend->expects($this->any())->method('getCalendarObjects')->willReturn([
30
+            $calObject0, $calObject1, $calObject2
31
+        ]);
32
+        $backend->expects($this->any())->method('getMultipleCalendarObjects')
33
+            ->with(666, ['event-0', 'event-1', 'event-2'])
34
+            ->willReturn([
35
+                $calObject0, $calObject1, $calObject2
36
+            ]);
37
+        $backend->expects($this->any())->method('getCalendarObject')
38
+            ->willReturn($calObject2)->with(666, 'event-2');
39
+        $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
40
+
41
+        $calendarInfo = [
42
+            '{http://owncloud.org/ns}owner-principal' => 'user2',
43
+            'principaluri' => 'user2',
44
+            'id' => 666,
45
+            'uri' => 'cal',
46
+        ];
47
+        /** @var IConfig&MockObject $config */
48
+        $config = $this->createMock(IConfig::class);
49
+        /** @var LoggerInterface&MockObject $logger */
50
+        $logger = $this->createMock(LoggerInterface::class);
51
+        $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger);
52
+        $children = $c->getChildren();
53
+        $this->assertEquals(2, count($children));
54
+        $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']);
55
+        $this->assertEquals(2, count($children));
56
+
57
+        $this->assertFalse($c->childExists('event-2'));
58
+    }
59
+
60
+    /**
61
+     * @dataProvider providesConfidentialClassificationData
62
+     */
63
+    public function testConfidentialClassification(int $expectedChildren, bool $isShared): void {
64
+        $start = '20160609';
65
+        $end = '20160610';
66
+
67
+        $calData = <<<EOD
68 68
 BEGIN:VCALENDAR
69 69
 PRODID:-//ownCloud calendar v1.2.2
70 70
 BEGIN:VEVENT
@@ -106,50 +106,50 @@  discard block
 block discarded – undo
106 106
 END:VCALENDAR
107 107
 EOD;
108 108
 
109
-		$calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC];
110
-		$calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData];
111
-		$calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE];
112
-
113
-		/** @var CalDavBackend&MockObject $backend */
114
-		$backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
115
-		$backend->expects($this->any())->method('getCalendarObjects')->willReturn([
116
-			$calObject0, $calObject1, $calObject2
117
-		]);
118
-		$backend->expects($this->any())->method('getMultipleCalendarObjects')
119
-			->with(666, ['event-0', 'event-1', 'event-2'])
120
-			->willReturn([
121
-				$calObject0, $calObject1, $calObject2
122
-			]);
123
-		$backend->expects($this->any())->method('getCalendarObject')
124
-			->willReturn($calObject1)->with(666, 'event-1');
125
-		$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
126
-
127
-		$calendarInfo = [
128
-			'{http://owncloud.org/ns}owner-principal' => 'user1',
129
-			'principaluri' => 'user2',
130
-			'id' => 666,
131
-			'uri' => 'cal',
132
-		];
133
-		/** @var IConfig&MockObject $config */
134
-		$config = $this->createMock(IConfig::class);
135
-		/** @var LoggerInterface&MockObject $logger */
136
-		$logger = $this->createMock(LoggerInterface::class);
137
-		$c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger);
138
-
139
-		$this->assertEquals(count($c->getChildren()), 2);
140
-
141
-		// test private event
142
-		$privateEvent = $c->getChild('event-1');
143
-		$calData = $privateEvent->get();
144
-		$event = Reader::read($calData);
145
-
146
-		$this->assertEquals($start, $event->VEVENT->DTSTART->getValue());
147
-		$this->assertEquals($end, $event->VEVENT->DTEND->getValue());
148
-
149
-		$this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue());
150
-		$this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT);
151
-		$this->assertArrayNotHasKey('LOCATION', $event->VEVENT);
152
-		$this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT);
153
-		$this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT);
154
-	}
109
+        $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC];
110
+        $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData];
111
+        $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE];
112
+
113
+        /** @var CalDavBackend&MockObject $backend */
114
+        $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
115
+        $backend->expects($this->any())->method('getCalendarObjects')->willReturn([
116
+            $calObject0, $calObject1, $calObject2
117
+        ]);
118
+        $backend->expects($this->any())->method('getMultipleCalendarObjects')
119
+            ->with(666, ['event-0', 'event-1', 'event-2'])
120
+            ->willReturn([
121
+                $calObject0, $calObject1, $calObject2
122
+            ]);
123
+        $backend->expects($this->any())->method('getCalendarObject')
124
+            ->willReturn($calObject1)->with(666, 'event-1');
125
+        $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
126
+
127
+        $calendarInfo = [
128
+            '{http://owncloud.org/ns}owner-principal' => 'user1',
129
+            'principaluri' => 'user2',
130
+            'id' => 666,
131
+            'uri' => 'cal',
132
+        ];
133
+        /** @var IConfig&MockObject $config */
134
+        $config = $this->createMock(IConfig::class);
135
+        /** @var LoggerInterface&MockObject $logger */
136
+        $logger = $this->createMock(LoggerInterface::class);
137
+        $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger);
138
+
139
+        $this->assertEquals(count($c->getChildren()), 2);
140
+
141
+        // test private event
142
+        $privateEvent = $c->getChild('event-1');
143
+        $calData = $privateEvent->get();
144
+        $event = Reader::read($calData);
145
+
146
+        $this->assertEquals($start, $event->VEVENT->DTSTART->getValue());
147
+        $this->assertEquals($end, $event->VEVENT->DTEND->getValue());
148
+
149
+        $this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue());
150
+        $this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT);
151
+        $this->assertArrayNotHasKey('LOCATION', $event->VEVENT);
152
+        $this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT);
153
+        $this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT);
154
+    }
155 155
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -21,122 +21,122 @@
 block discarded – undo
21 21
 use Test\TestCase;
22 22
 
23 23
 class TimezoneServiceTest extends TestCase {
24
-	private IConfig&MockObject $config;
25
-	private PropertyMapper&MockObject $propertyMapper;
26
-	private IManager&MockObject $calendarManager;
27
-	private TimezoneService $service;
28
-
29
-	protected function setUp(): void {
30
-		parent::setUp();
31
-
32
-		$this->config = $this->createMock(IConfig::class);
33
-		$this->propertyMapper = $this->createMock(PropertyMapper::class);
34
-		$this->calendarManager = $this->createMock(IManager::class);
35
-
36
-		$this->service = new TimezoneService(
37
-			$this->config,
38
-			$this->propertyMapper,
39
-			$this->calendarManager,
40
-		);
41
-	}
42
-
43
-	public function testGetUserTimezoneFromSettings(): void {
44
-		$this->config->expects(self::once())
45
-			->method('getUserValue')
46
-			->with('test123', 'core', 'timezone', '')
47
-			->willReturn('Europe/Warsaw');
48
-
49
-		$timezone = $this->service->getUserTimezone('test123');
50
-
51
-		self::assertSame('Europe/Warsaw', $timezone);
52
-	}
53
-
54
-	public function testGetUserTimezoneFromAvailability(): void {
55
-		$this->config->expects(self::once())
56
-			->method('getUserValue')
57
-			->with('test123', 'core', 'timezone', '')
58
-			->willReturn('');
59
-		$property = new Property();
60
-		$property->setPropertyvalue('BEGIN:VCALENDAR
24
+    private IConfig&MockObject $config;
25
+    private PropertyMapper&MockObject $propertyMapper;
26
+    private IManager&MockObject $calendarManager;
27
+    private TimezoneService $service;
28
+
29
+    protected function setUp(): void {
30
+        parent::setUp();
31
+
32
+        $this->config = $this->createMock(IConfig::class);
33
+        $this->propertyMapper = $this->createMock(PropertyMapper::class);
34
+        $this->calendarManager = $this->createMock(IManager::class);
35
+
36
+        $this->service = new TimezoneService(
37
+            $this->config,
38
+            $this->propertyMapper,
39
+            $this->calendarManager,
40
+        );
41
+    }
42
+
43
+    public function testGetUserTimezoneFromSettings(): void {
44
+        $this->config->expects(self::once())
45
+            ->method('getUserValue')
46
+            ->with('test123', 'core', 'timezone', '')
47
+            ->willReturn('Europe/Warsaw');
48
+
49
+        $timezone = $this->service->getUserTimezone('test123');
50
+
51
+        self::assertSame('Europe/Warsaw', $timezone);
52
+    }
53
+
54
+    public function testGetUserTimezoneFromAvailability(): void {
55
+        $this->config->expects(self::once())
56
+            ->method('getUserValue')
57
+            ->with('test123', 'core', 'timezone', '')
58
+            ->willReturn('');
59
+        $property = new Property();
60
+        $property->setPropertyvalue('BEGIN:VCALENDAR
61 61
 PRODID:Nextcloud DAV app
62 62
 BEGIN:VTIMEZONE
63 63
 TZID:Europe/Vienna
64 64
 END:VTIMEZONE
65 65
 END:VCALENDAR');
66
-		$this->propertyMapper->expects(self::once())
67
-			->method('findPropertyByPathAndName')
68
-			->willReturn([
69
-				$property,
70
-			]);
71
-
72
-		$timezone = $this->service->getUserTimezone('test123');
73
-
74
-		self::assertNotNull($timezone);
75
-		self::assertEquals('Europe/Vienna', $timezone);
76
-	}
77
-
78
-	public function testGetUserTimezoneFromPersonalCalendar(): void {
79
-		$this->config->expects(self::exactly(2))
80
-			->method('getUserValue')
81
-			->willReturnMap([
82
-				['test123', 'core', 'timezone', '', ''],
83
-				['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
84
-			]);
85
-		$other = $this->createMock(ICalendar::class);
86
-		$other->method('getUri')->willReturn('other');
87
-		$personal = $this->createMock(CalendarImpl::class);
88
-		$personal->method('getUri')->willReturn('personal-1');
89
-		$tz = new DateTimeZone('Europe/Berlin');
90
-		$vtz = $this->createMock(VTimeZone::class);
91
-		$vtz->method('getTimeZone')->willReturn($tz);
92
-		$personal->method('getSchedulingTimezone')->willReturn($vtz);
93
-		$this->calendarManager->expects(self::once())
94
-			->method('getCalendarsForPrincipal')
95
-			->with('principals/users/test123')
96
-			->willReturn([
97
-				$other,
98
-				$personal,
99
-			]);
100
-
101
-		$timezone = $this->service->getUserTimezone('test123');
102
-
103
-		self::assertNotNull($timezone);
104
-		self::assertEquals('Europe/Berlin', $timezone);
105
-	}
106
-
107
-	public function testGetUserTimezoneFromAny(): void {
108
-		$this->config->expects(self::exactly(2))
109
-			->method('getUserValue')
110
-			->willReturnMap([
111
-				['test123', 'core', 'timezone', '', ''],
112
-				['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
113
-			]);
114
-		$other = $this->createMock(ICalendar::class);
115
-		$other->method('getUri')->willReturn('other');
116
-		$personal = $this->createMock(CalendarImpl::class);
117
-		$personal->method('getUri')->willReturn('personal-2');
118
-		$tz = new DateTimeZone('Europe/Prague');
119
-		$vtz = $this->createMock(VTimeZone::class);
120
-		$vtz->method('getTimeZone')->willReturn($tz);
121
-		$personal->method('getSchedulingTimezone')->willReturn($vtz);
122
-		$this->calendarManager->expects(self::once())
123
-			->method('getCalendarsForPrincipal')
124
-			->with('principals/users/test123')
125
-			->willReturn([
126
-				$other,
127
-				$personal,
128
-			]);
129
-
130
-		$timezone = $this->service->getUserTimezone('test123');
131
-
132
-		self::assertNotNull($timezone);
133
-		self::assertEquals('Europe/Prague', $timezone);
134
-	}
135
-
136
-	public function testGetUserTimezoneNoneFound(): void {
137
-		$timezone = $this->service->getUserTimezone('test123');
138
-
139
-		self::assertNull($timezone);
140
-	}
66
+        $this->propertyMapper->expects(self::once())
67
+            ->method('findPropertyByPathAndName')
68
+            ->willReturn([
69
+                $property,
70
+            ]);
71
+
72
+        $timezone = $this->service->getUserTimezone('test123');
73
+
74
+        self::assertNotNull($timezone);
75
+        self::assertEquals('Europe/Vienna', $timezone);
76
+    }
77
+
78
+    public function testGetUserTimezoneFromPersonalCalendar(): void {
79
+        $this->config->expects(self::exactly(2))
80
+            ->method('getUserValue')
81
+            ->willReturnMap([
82
+                ['test123', 'core', 'timezone', '', ''],
83
+                ['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
84
+            ]);
85
+        $other = $this->createMock(ICalendar::class);
86
+        $other->method('getUri')->willReturn('other');
87
+        $personal = $this->createMock(CalendarImpl::class);
88
+        $personal->method('getUri')->willReturn('personal-1');
89
+        $tz = new DateTimeZone('Europe/Berlin');
90
+        $vtz = $this->createMock(VTimeZone::class);
91
+        $vtz->method('getTimeZone')->willReturn($tz);
92
+        $personal->method('getSchedulingTimezone')->willReturn($vtz);
93
+        $this->calendarManager->expects(self::once())
94
+            ->method('getCalendarsForPrincipal')
95
+            ->with('principals/users/test123')
96
+            ->willReturn([
97
+                $other,
98
+                $personal,
99
+            ]);
100
+
101
+        $timezone = $this->service->getUserTimezone('test123');
102
+
103
+        self::assertNotNull($timezone);
104
+        self::assertEquals('Europe/Berlin', $timezone);
105
+    }
106
+
107
+    public function testGetUserTimezoneFromAny(): void {
108
+        $this->config->expects(self::exactly(2))
109
+            ->method('getUserValue')
110
+            ->willReturnMap([
111
+                ['test123', 'core', 'timezone', '', ''],
112
+                ['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
113
+            ]);
114
+        $other = $this->createMock(ICalendar::class);
115
+        $other->method('getUri')->willReturn('other');
116
+        $personal = $this->createMock(CalendarImpl::class);
117
+        $personal->method('getUri')->willReturn('personal-2');
118
+        $tz = new DateTimeZone('Europe/Prague');
119
+        $vtz = $this->createMock(VTimeZone::class);
120
+        $vtz->method('getTimeZone')->willReturn($tz);
121
+        $personal->method('getSchedulingTimezone')->willReturn($vtz);
122
+        $this->calendarManager->expects(self::once())
123
+            ->method('getCalendarsForPrincipal')
124
+            ->with('principals/users/test123')
125
+            ->willReturn([
126
+                $other,
127
+                $personal,
128
+            ]);
129
+
130
+        $timezone = $this->service->getUserTimezone('test123');
131
+
132
+        self::assertNotNull($timezone);
133
+        self::assertEquals('Europe/Prague', $timezone);
134
+    }
135
+
136
+    public function testGetUserTimezoneNoneFound(): void {
137
+        $timezone = $this->service->getUserTimezone('test123');
138
+
139
+        self::assertNull($timezone);
140
+    }
141 141
 
142 142
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/Integration/ExternalCalendarTest.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -12,92 +12,92 @@
 block discarded – undo
12 12
 use Test\TestCase;
13 13
 
14 14
 class ExternalCalendarTest extends TestCase {
15
-	private ExternalCalendar&MockObject $abstractExternalCalendar;
16
-
17
-	protected function setUp(): void {
18
-		parent::setUp();
19
-
20
-		$this->abstractExternalCalendar =
21
-			$this->getMockForAbstractClass(ExternalCalendar::class, ['example-app-id', 'calendar-uri-in-backend']);
22
-	}
23
-
24
-	public function testGetName():void {
25
-		// Check that the correct name is returned
26
-		$this->assertEquals('app-generated--example-app-id--calendar-uri-in-backend',
27
-			$this->abstractExternalCalendar->getName());
28
-
29
-		// Check that the method is final and can't be overridden by other classes
30
-		$reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'getName');
31
-		$this->assertTrue($reflectionMethod->isFinal());
32
-	}
33
-
34
-	public function testSetName():void {
35
-		// Check that the method is final and can't be overridden by other classes
36
-		$reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'setName');
37
-		$this->assertTrue($reflectionMethod->isFinal());
38
-
39
-		$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
40
-		$this->expectExceptionMessage('Renaming calendars is not yet supported');
41
-
42
-		$this->abstractExternalCalendar->setName('other-name');
43
-	}
44
-
45
-	public function createDirectory(): void {
46
-		// Check that the method is final and can't be overridden by other classes
47
-		$reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'createDirectory');
48
-		$this->assertTrue($reflectionMethod->isFinal());
49
-
50
-		$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
51
-		$this->expectExceptionMessage('Creating collections in calendar objects is not allowed');
52
-
53
-		$this->abstractExternalCalendar->createDirectory('other-name');
54
-	}
55
-
56
-	public function testIsAppGeneratedCalendar():void {
57
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('personal'));
58
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('work'));
59
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('contact_birthdays'));
60
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('company'));
61
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('app-generated'));
62
-		$this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('app-generated--example'));
63
-
64
-		$this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--deck--board-1'));
65
-		$this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--example--foo-2'));
66
-		$this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--example--foo--2'));
67
-	}
68
-
69
-	/**
70
-	 * @dataProvider splitAppGeneratedCalendarUriDataProvider
71
-	 */
72
-	public function testSplitAppGeneratedCalendarUriInvalid(string $name):void {
73
-		$this->expectException(\InvalidArgumentException::class);
74
-		$this->expectExceptionMessage('Provided calendar uri was not app-generated');
75
-
76
-		ExternalCalendar::splitAppGeneratedCalendarUri($name);
77
-	}
78
-
79
-	public static function splitAppGeneratedCalendarUriDataProvider():array {
80
-		return [
81
-			['personal'],
82
-			['foo_shared_by_admin'],
83
-			['contact_birthdays'],
84
-		];
85
-	}
86
-
87
-	public function testSplitAppGeneratedCalendarUri():void {
88
-		$this->assertEquals(['deck', 'board-1'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--deck--board-1'));
89
-		$this->assertEquals(['example', 'foo-2'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--example--foo-2'));
90
-		$this->assertEquals(['example', 'foo--2'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--example--foo--2'));
91
-	}
92
-
93
-	public function testDoesViolateReservedName():void {
94
-		$this->assertFalse(ExternalCalendar::doesViolateReservedName('personal'));
95
-		$this->assertFalse(ExternalCalendar::doesViolateReservedName('work'));
96
-		$this->assertFalse(ExternalCalendar::doesViolateReservedName('contact_birthdays'));
97
-		$this->assertFalse(ExternalCalendar::doesViolateReservedName('company'));
98
-
99
-		$this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated'));
100
-		$this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated-calendar'));
101
-		$this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated--deck-123'));
102
-	}
15
+    private ExternalCalendar&MockObject $abstractExternalCalendar;
16
+
17
+    protected function setUp(): void {
18
+        parent::setUp();
19
+
20
+        $this->abstractExternalCalendar =
21
+            $this->getMockForAbstractClass(ExternalCalendar::class, ['example-app-id', 'calendar-uri-in-backend']);
22
+    }
23
+
24
+    public function testGetName():void {
25
+        // Check that the correct name is returned
26
+        $this->assertEquals('app-generated--example-app-id--calendar-uri-in-backend',
27
+            $this->abstractExternalCalendar->getName());
28
+
29
+        // Check that the method is final and can't be overridden by other classes
30
+        $reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'getName');
31
+        $this->assertTrue($reflectionMethod->isFinal());
32
+    }
33
+
34
+    public function testSetName():void {
35
+        // Check that the method is final and can't be overridden by other classes
36
+        $reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'setName');
37
+        $this->assertTrue($reflectionMethod->isFinal());
38
+
39
+        $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
40
+        $this->expectExceptionMessage('Renaming calendars is not yet supported');
41
+
42
+        $this->abstractExternalCalendar->setName('other-name');
43
+    }
44
+
45
+    public function createDirectory(): void {
46
+        // Check that the method is final and can't be overridden by other classes
47
+        $reflectionMethod = new \ReflectionMethod(ExternalCalendar::class, 'createDirectory');
48
+        $this->assertTrue($reflectionMethod->isFinal());
49
+
50
+        $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
51
+        $this->expectExceptionMessage('Creating collections in calendar objects is not allowed');
52
+
53
+        $this->abstractExternalCalendar->createDirectory('other-name');
54
+    }
55
+
56
+    public function testIsAppGeneratedCalendar():void {
57
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('personal'));
58
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('work'));
59
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('contact_birthdays'));
60
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('company'));
61
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('app-generated'));
62
+        $this->assertFalse(ExternalCalendar::isAppGeneratedCalendar('app-generated--example'));
63
+
64
+        $this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--deck--board-1'));
65
+        $this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--example--foo-2'));
66
+        $this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--example--foo--2'));
67
+    }
68
+
69
+    /**
70
+     * @dataProvider splitAppGeneratedCalendarUriDataProvider
71
+     */
72
+    public function testSplitAppGeneratedCalendarUriInvalid(string $name):void {
73
+        $this->expectException(\InvalidArgumentException::class);
74
+        $this->expectExceptionMessage('Provided calendar uri was not app-generated');
75
+
76
+        ExternalCalendar::splitAppGeneratedCalendarUri($name);
77
+    }
78
+
79
+    public static function splitAppGeneratedCalendarUriDataProvider():array {
80
+        return [
81
+            ['personal'],
82
+            ['foo_shared_by_admin'],
83
+            ['contact_birthdays'],
84
+        ];
85
+    }
86
+
87
+    public function testSplitAppGeneratedCalendarUri():void {
88
+        $this->assertEquals(['deck', 'board-1'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--deck--board-1'));
89
+        $this->assertEquals(['example', 'foo-2'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--example--foo-2'));
90
+        $this->assertEquals(['example', 'foo--2'], ExternalCalendar::splitAppGeneratedCalendarUri('app-generated--example--foo--2'));
91
+    }
92
+
93
+    public function testDoesViolateReservedName():void {
94
+        $this->assertFalse(ExternalCalendar::doesViolateReservedName('personal'));
95
+        $this->assertFalse(ExternalCalendar::doesViolateReservedName('work'));
96
+        $this->assertFalse(ExternalCalendar::doesViolateReservedName('contact_birthdays'));
97
+        $this->assertFalse(ExternalCalendar::doesViolateReservedName('company'));
98
+
99
+        $this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated'));
100
+        $this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated-calendar'));
101
+        $this->assertTrue(ExternalCalendar::doesViolateReservedName('app-generated--deck-123'));
102
+    }
103 103
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/Status/StatusServiceTest.php 1 patch
Indentation   +415 added lines, -415 removed lines patch added patch discarded remove patch
@@ -27,419 +27,419 @@
 block discarded – undo
27 27
 use Test\TestCase;
28 28
 
29 29
 class StatusServiceTest extends TestCase {
30
-	private ITimeFactory&MockObject $timeFactory;
31
-	private IManager&MockObject $calendarManager;
32
-	private IUserManager&MockObject $userManager;
33
-	private UserStatusService&MockObject $userStatusService;
34
-	private IAvailabilityCoordinator&MockObject $availabilityCoordinator;
35
-	private ICacheFactory&MockObject $cacheFactory;
36
-	private LoggerInterface&MockObject $logger;
37
-	private ICache&MockObject $cache;
38
-	private StatusService $service;
39
-
40
-	protected function setUp(): void {
41
-		parent::setUp();
42
-
43
-		$this->timeFactory = $this->createMock(ITimeFactory::class);
44
-		$this->calendarManager = $this->createMock(IManager::class);
45
-		$this->userManager = $this->createMock(IUserManager::class);
46
-		$this->userStatusService = $this->createMock(UserStatusService::class);
47
-		$this->availabilityCoordinator = $this->createMock(IAvailabilityCoordinator::class);
48
-		$this->cacheFactory = $this->createMock(ICacheFactory::class);
49
-		$this->logger = $this->createMock(LoggerInterface::class);
50
-		$this->cache = $this->createMock(ICache::class);
51
-		$this->cacheFactory->expects(self::once())
52
-			->method('createLocal')
53
-			->with('CalendarStatusService')
54
-			->willReturn($this->cache);
55
-
56
-		$this->service = new StatusService($this->timeFactory,
57
-			$this->calendarManager,
58
-			$this->userManager,
59
-			$this->userStatusService,
60
-			$this->availabilityCoordinator,
61
-			$this->cacheFactory,
62
-			$this->logger,
63
-		);
64
-	}
65
-
66
-	public function testNoUser(): void {
67
-		$this->userManager->expects(self::once())
68
-			->method('get')
69
-			->willReturn(null);
70
-		$this->availabilityCoordinator->expects(self::never())
71
-			->method('getCurrentOutOfOfficeData');
72
-		$this->availabilityCoordinator->expects(self::never())
73
-			->method('isInEffect');
74
-		$this->logger->expects(self::never())
75
-			->method('debug');
76
-		$this->cache->expects(self::never())
77
-			->method('get');
78
-		$this->cache->expects(self::never())
79
-			->method('set');
80
-		$this->calendarManager->expects(self::never())
81
-			->method('getCalendarsForPrincipal');
82
-		$this->calendarManager->expects(self::never())
83
-			->method('newQuery');
84
-		$this->timeFactory->expects(self::never())
85
-			->method('getDateTime');
86
-		$this->calendarManager->expects(self::never())
87
-			->method('searchForPrincipal');
88
-		$this->userStatusService->expects(self::never())
89
-			->method('revertUserStatus');
90
-		$this->userStatusService->expects(self::never())
91
-			->method('setUserStatus');
92
-		$this->userStatusService->expects(self::never())
93
-			->method('findByUserId');
94
-
95
-		$this->service->processCalendarStatus('admin');
96
-	}
97
-
98
-	public function testOOOInEffect(): void {
99
-		$user = $this->createConfiguredMock(IUser::class, [
100
-			'getUID' => 'admin',
101
-		]);
102
-
103
-		$this->userManager->expects(self::once())
104
-			->method('get')
105
-			->willReturn($user);
106
-		$this->availabilityCoordinator->expects(self::once())
107
-			->method('getCurrentOutOfOfficeData')
108
-			->willReturn($this->createMock(IOutOfOfficeData::class));
109
-		$this->availabilityCoordinator->expects(self::once())
110
-			->method('isInEffect')
111
-			->willReturn(true);
112
-		$this->logger->expects(self::once())
113
-			->method('debug');
114
-		$this->cache->expects(self::never())
115
-			->method('get');
116
-		$this->cache->expects(self::never())
117
-			->method('set');
118
-		$this->calendarManager->expects(self::never())
119
-			->method('getCalendarsForPrincipal');
120
-		$this->calendarManager->expects(self::never())
121
-			->method('newQuery');
122
-		$this->timeFactory->expects(self::never())
123
-			->method('getDateTime');
124
-		$this->calendarManager->expects(self::never())
125
-			->method('searchForPrincipal');
126
-		$this->userStatusService->expects(self::never())
127
-			->method('revertUserStatus');
128
-		$this->userStatusService->expects(self::never())
129
-			->method('setUserStatus');
130
-		$this->userStatusService->expects(self::never())
131
-			->method('findByUserId');
132
-
133
-		$this->service->processCalendarStatus('admin');
134
-	}
135
-
136
-	public function testNoCalendars(): void {
137
-		$user = $this->createConfiguredMock(IUser::class, [
138
-			'getUID' => 'admin',
139
-		]);
140
-
141
-		$this->userManager->expects(self::once())
142
-			->method('get')
143
-			->willReturn($user);
144
-		$this->availabilityCoordinator->expects(self::once())
145
-			->method('getCurrentOutOfOfficeData')
146
-			->willReturn(null);
147
-		$this->availabilityCoordinator->expects(self::never())
148
-			->method('isInEffect');
149
-		$this->cache->expects(self::once())
150
-			->method('get')
151
-			->willReturn(null);
152
-		$this->cache->expects(self::once())
153
-			->method('set');
154
-		$this->calendarManager->expects(self::once())
155
-			->method('getCalendarsForPrincipal')
156
-			->willReturn([]);
157
-		$this->calendarManager->expects(self::never())
158
-			->method('newQuery');
159
-		$this->timeFactory->expects(self::never())
160
-			->method('getDateTime');
161
-		$this->calendarManager->expects(self::never())
162
-			->method('searchForPrincipal');
163
-		$this->userStatusService->expects(self::once())
164
-			->method('revertUserStatus');
165
-		$this->logger->expects(self::once())
166
-			->method('debug');
167
-		$this->userStatusService->expects(self::never())
168
-			->method('setUserStatus');
169
-		$this->userStatusService->expects(self::never())
170
-			->method('findByUserId');
171
-
172
-		$this->service->processCalendarStatus('admin');
173
-	}
174
-
175
-	public function testNoCalendarEvents(): void {
176
-		$user = $this->createConfiguredMock(IUser::class, [
177
-			'getUID' => 'admin',
178
-		]);
179
-
180
-		$this->userManager->expects(self::once())
181
-			->method('get')
182
-			->willReturn($user);
183
-		$this->availabilityCoordinator->expects(self::once())
184
-			->method('getCurrentOutOfOfficeData')
185
-			->willReturn(null);
186
-		$this->availabilityCoordinator->expects(self::never())
187
-			->method('isInEffect');
188
-		$this->cache->expects(self::once())
189
-			->method('get')
190
-			->willReturn(null);
191
-		$this->cache->expects(self::once())
192
-			->method('set');
193
-		$this->calendarManager->expects(self::once())
194
-			->method('getCalendarsForPrincipal')
195
-			->willReturn([$this->createMock(CalendarImpl::class)]);
196
-		$this->calendarManager->expects(self::once())
197
-			->method('newQuery')
198
-			->willReturn(new CalendarQuery('admin'));
199
-		$this->timeFactory->expects(self::exactly(2))
200
-			->method('getDateTime')
201
-			->willReturn(new \DateTime());
202
-		$this->calendarManager->expects(self::once())
203
-			->method('searchForPrincipal')
204
-			->willReturn([]);
205
-		$this->userStatusService->expects(self::once())
206
-			->method('revertUserStatus');
207
-		$this->logger->expects(self::once())
208
-			->method('debug');
209
-		$this->userStatusService->expects(self::never())
210
-			->method('setUserStatus');
211
-		$this->userStatusService->expects(self::never())
212
-			->method('findByUserId');
213
-
214
-		$this->service->processCalendarStatus('admin');
215
-	}
216
-
217
-	public function testCalendarNoEventObjects(): void {
218
-		$user = $this->createConfiguredMock(IUser::class, [
219
-			'getUID' => 'admin',
220
-		]);
221
-
222
-		$this->userManager->expects(self::once())
223
-			->method('get')
224
-			->willReturn($user);
225
-		$this->availabilityCoordinator->expects(self::once())
226
-			->method('getCurrentOutOfOfficeData')
227
-			->willReturn(null);
228
-		$this->availabilityCoordinator->expects(self::never())
229
-			->method('isInEffect');
230
-		$this->cache->expects(self::once())
231
-			->method('get')
232
-			->willReturn(null);
233
-		$this->cache->expects(self::once())
234
-			->method('set');
235
-		$this->calendarManager->expects(self::once())
236
-			->method('getCalendarsForPrincipal')
237
-			->willReturn([$this->createMock(CalendarImpl::class)]);
238
-		$this->calendarManager->expects(self::once())
239
-			->method('newQuery')
240
-			->willReturn(new CalendarQuery('admin'));
241
-		$this->timeFactory->expects(self::exactly(2))
242
-			->method('getDateTime')
243
-			->willReturn(new \DateTime());
244
-		$this->userStatusService->expects(self::once())
245
-			->method('findByUserId')
246
-			->willThrowException(new DoesNotExistException(''));
247
-		$this->calendarManager->expects(self::once())
248
-			->method('searchForPrincipal')
249
-			->willReturn([['objects' => []]]);
250
-		$this->userStatusService->expects(self::once())
251
-			->method('revertUserStatus');
252
-		$this->logger->expects(self::once())
253
-			->method('debug');
254
-		$this->userStatusService->expects(self::never())
255
-			->method('setUserStatus');
256
-
257
-
258
-		$this->service->processCalendarStatus('admin');
259
-	}
260
-
261
-	public function testCalendarEvent(): void {
262
-		$user = $this->createConfiguredMock(IUser::class, [
263
-			'getUID' => 'admin',
264
-		]);
265
-
266
-		$this->userManager->expects(self::once())
267
-			->method('get')
268
-			->willReturn($user);
269
-		$this->availabilityCoordinator->expects(self::once())
270
-			->method('getCurrentOutOfOfficeData')
271
-			->willReturn(null);
272
-		$this->availabilityCoordinator->expects(self::never())
273
-			->method('isInEffect');
274
-		$this->cache->expects(self::once())
275
-			->method('get')
276
-			->willReturn(null);
277
-		$this->cache->expects(self::once())
278
-			->method('set');
279
-		$this->calendarManager->expects(self::once())
280
-			->method('getCalendarsForPrincipal')
281
-			->willReturn([$this->createMock(CalendarImpl::class)]);
282
-		$this->calendarManager->expects(self::once())
283
-			->method('newQuery')
284
-			->willReturn(new CalendarQuery('admin'));
285
-		$this->timeFactory->expects(self::exactly(2))
286
-			->method('getDateTime')
287
-			->willReturn(new \DateTime());
288
-		$this->userStatusService->expects(self::once())
289
-			->method('findByUserId')
290
-			->willThrowException(new DoesNotExistException(''));
291
-		$this->calendarManager->expects(self::once())
292
-			->method('searchForPrincipal')
293
-			->willReturn([['objects' => [[]]]]);
294
-		$this->userStatusService->expects(self::never())
295
-			->method('revertUserStatus');
296
-		$this->logger->expects(self::once())
297
-			->method('debug');
298
-		$this->userStatusService->expects(self::once())
299
-			->method('setUserStatus');
300
-
301
-
302
-		$this->service->processCalendarStatus('admin');
303
-	}
304
-
305
-	public function testCallStatus(): void {
306
-		$user = $this->createConfiguredMock(IUser::class, [
307
-			'getUID' => 'admin',
308
-		]);
309
-
310
-		$this->userManager->expects(self::once())
311
-			->method('get')
312
-			->willReturn($user);
313
-		$this->availabilityCoordinator->expects(self::once())
314
-			->method('getCurrentOutOfOfficeData')
315
-			->willReturn(null);
316
-		$this->availabilityCoordinator->expects(self::never())
317
-			->method('isInEffect');
318
-		$this->cache->expects(self::once())
319
-			->method('get')
320
-			->willReturn(null);
321
-		$this->cache->expects(self::once())
322
-			->method('set');
323
-		$this->calendarManager->expects(self::once())
324
-			->method('getCalendarsForPrincipal')
325
-			->willReturn([$this->createMock(CalendarImpl::class)]);
326
-		$this->calendarManager->expects(self::once())
327
-			->method('newQuery')
328
-			->willReturn(new CalendarQuery('admin'));
329
-		$this->timeFactory->expects(self::exactly(2))
330
-			->method('getDateTime')
331
-			->willReturn(new \DateTime());
332
-		$this->calendarManager->expects(self::once())
333
-			->method('searchForPrincipal')
334
-			->willReturn([['objects' => [[]]]]);
335
-		$userStatus = new UserStatus();
336
-		$userStatus->setMessageId(IUserStatus::MESSAGE_CALL);
337
-		$userStatus->setStatusTimestamp(123456);
338
-		$this->userStatusService->expects(self::once())
339
-			->method('findByUserId')
340
-			->willReturn($userStatus);
341
-		$this->logger->expects(self::once())
342
-			->method('debug');
343
-		$this->userStatusService->expects(self::never())
344
-			->method('revertUserStatus');
345
-		$this->userStatusService->expects(self::never())
346
-			->method('setUserStatus');
347
-
348
-
349
-		$this->service->processCalendarStatus('admin');
350
-	}
351
-
352
-	public function testInvisibleStatus(): void {
353
-		$user = $this->createConfiguredMock(IUser::class, [
354
-			'getUID' => 'admin',
355
-		]);
356
-
357
-		$this->userManager->expects(self::once())
358
-			->method('get')
359
-			->willReturn($user);
360
-		$this->availabilityCoordinator->expects(self::once())
361
-			->method('getCurrentOutOfOfficeData')
362
-			->willReturn(null);
363
-		$this->availabilityCoordinator->expects(self::never())
364
-			->method('isInEffect');
365
-		$this->cache->expects(self::once())
366
-			->method('get')
367
-			->willReturn(null);
368
-		$this->cache->expects(self::once())
369
-			->method('set');
370
-		$this->calendarManager->expects(self::once())
371
-			->method('getCalendarsForPrincipal')
372
-			->willReturn([$this->createMock(CalendarImpl::class)]);
373
-		$this->calendarManager->expects(self::once())
374
-			->method('newQuery')
375
-			->willReturn(new CalendarQuery('admin'));
376
-		$this->timeFactory->expects(self::exactly(2))
377
-			->method('getDateTime')
378
-			->willReturn(new \DateTime());
379
-		$this->calendarManager->expects(self::once())
380
-			->method('searchForPrincipal')
381
-			->willReturn([['objects' => [[]]]]);
382
-		$userStatus = new UserStatus();
383
-		$userStatus->setStatus(IUserStatus::INVISIBLE);
384
-		$userStatus->setStatusTimestamp(123456);
385
-		$this->userStatusService->expects(self::once())
386
-			->method('findByUserId')
387
-			->willReturn($userStatus);
388
-		$this->logger->expects(self::once())
389
-			->method('debug');
390
-		$this->userStatusService->expects(self::never())
391
-			->method('revertUserStatus');
392
-		$this->userStatusService->expects(self::never())
393
-			->method('setUserStatus');
394
-
395
-
396
-		$this->service->processCalendarStatus('admin');
397
-	}
398
-
399
-	public function testDNDStatus(): void {
400
-		$user = $this->createConfiguredMock(IUser::class, [
401
-			'getUID' => 'admin',
402
-		]);
403
-
404
-		$this->userManager->expects(self::once())
405
-			->method('get')
406
-			->willReturn($user);
407
-		$this->availabilityCoordinator->expects(self::once())
408
-			->method('getCurrentOutOfOfficeData')
409
-			->willReturn(null);
410
-		$this->availabilityCoordinator->expects(self::never())
411
-			->method('isInEffect');
412
-		$this->cache->expects(self::once())
413
-			->method('get')
414
-			->willReturn(null);
415
-		$this->cache->expects(self::once())
416
-			->method('set');
417
-		$this->calendarManager->expects(self::once())
418
-			->method('getCalendarsForPrincipal')
419
-			->willReturn([$this->createMock(CalendarImpl::class)]);
420
-		$this->calendarManager->expects(self::once())
421
-			->method('newQuery')
422
-			->willReturn(new CalendarQuery('admin'));
423
-		$this->timeFactory->expects(self::exactly(2))
424
-			->method('getDateTime')
425
-			->willReturn(new \DateTime());
426
-		$this->calendarManager->expects(self::once())
427
-			->method('searchForPrincipal')
428
-			->willReturn([['objects' => [[]]]]);
429
-		$userStatus = new UserStatus();
430
-		$userStatus->setStatus(IUserStatus::DND);
431
-		$userStatus->setStatusTimestamp(123456);
432
-		$this->userStatusService->expects(self::once())
433
-			->method('findByUserId')
434
-			->willReturn($userStatus);
435
-		$this->logger->expects(self::once())
436
-			->method('debug');
437
-		$this->userStatusService->expects(self::never())
438
-			->method('revertUserStatus');
439
-		$this->userStatusService->expects(self::never())
440
-			->method('setUserStatus');
441
-
442
-
443
-		$this->service->processCalendarStatus('admin');
444
-	}
30
+    private ITimeFactory&MockObject $timeFactory;
31
+    private IManager&MockObject $calendarManager;
32
+    private IUserManager&MockObject $userManager;
33
+    private UserStatusService&MockObject $userStatusService;
34
+    private IAvailabilityCoordinator&MockObject $availabilityCoordinator;
35
+    private ICacheFactory&MockObject $cacheFactory;
36
+    private LoggerInterface&MockObject $logger;
37
+    private ICache&MockObject $cache;
38
+    private StatusService $service;
39
+
40
+    protected function setUp(): void {
41
+        parent::setUp();
42
+
43
+        $this->timeFactory = $this->createMock(ITimeFactory::class);
44
+        $this->calendarManager = $this->createMock(IManager::class);
45
+        $this->userManager = $this->createMock(IUserManager::class);
46
+        $this->userStatusService = $this->createMock(UserStatusService::class);
47
+        $this->availabilityCoordinator = $this->createMock(IAvailabilityCoordinator::class);
48
+        $this->cacheFactory = $this->createMock(ICacheFactory::class);
49
+        $this->logger = $this->createMock(LoggerInterface::class);
50
+        $this->cache = $this->createMock(ICache::class);
51
+        $this->cacheFactory->expects(self::once())
52
+            ->method('createLocal')
53
+            ->with('CalendarStatusService')
54
+            ->willReturn($this->cache);
55
+
56
+        $this->service = new StatusService($this->timeFactory,
57
+            $this->calendarManager,
58
+            $this->userManager,
59
+            $this->userStatusService,
60
+            $this->availabilityCoordinator,
61
+            $this->cacheFactory,
62
+            $this->logger,
63
+        );
64
+    }
65
+
66
+    public function testNoUser(): void {
67
+        $this->userManager->expects(self::once())
68
+            ->method('get')
69
+            ->willReturn(null);
70
+        $this->availabilityCoordinator->expects(self::never())
71
+            ->method('getCurrentOutOfOfficeData');
72
+        $this->availabilityCoordinator->expects(self::never())
73
+            ->method('isInEffect');
74
+        $this->logger->expects(self::never())
75
+            ->method('debug');
76
+        $this->cache->expects(self::never())
77
+            ->method('get');
78
+        $this->cache->expects(self::never())
79
+            ->method('set');
80
+        $this->calendarManager->expects(self::never())
81
+            ->method('getCalendarsForPrincipal');
82
+        $this->calendarManager->expects(self::never())
83
+            ->method('newQuery');
84
+        $this->timeFactory->expects(self::never())
85
+            ->method('getDateTime');
86
+        $this->calendarManager->expects(self::never())
87
+            ->method('searchForPrincipal');
88
+        $this->userStatusService->expects(self::never())
89
+            ->method('revertUserStatus');
90
+        $this->userStatusService->expects(self::never())
91
+            ->method('setUserStatus');
92
+        $this->userStatusService->expects(self::never())
93
+            ->method('findByUserId');
94
+
95
+        $this->service->processCalendarStatus('admin');
96
+    }
97
+
98
+    public function testOOOInEffect(): void {
99
+        $user = $this->createConfiguredMock(IUser::class, [
100
+            'getUID' => 'admin',
101
+        ]);
102
+
103
+        $this->userManager->expects(self::once())
104
+            ->method('get')
105
+            ->willReturn($user);
106
+        $this->availabilityCoordinator->expects(self::once())
107
+            ->method('getCurrentOutOfOfficeData')
108
+            ->willReturn($this->createMock(IOutOfOfficeData::class));
109
+        $this->availabilityCoordinator->expects(self::once())
110
+            ->method('isInEffect')
111
+            ->willReturn(true);
112
+        $this->logger->expects(self::once())
113
+            ->method('debug');
114
+        $this->cache->expects(self::never())
115
+            ->method('get');
116
+        $this->cache->expects(self::never())
117
+            ->method('set');
118
+        $this->calendarManager->expects(self::never())
119
+            ->method('getCalendarsForPrincipal');
120
+        $this->calendarManager->expects(self::never())
121
+            ->method('newQuery');
122
+        $this->timeFactory->expects(self::never())
123
+            ->method('getDateTime');
124
+        $this->calendarManager->expects(self::never())
125
+            ->method('searchForPrincipal');
126
+        $this->userStatusService->expects(self::never())
127
+            ->method('revertUserStatus');
128
+        $this->userStatusService->expects(self::never())
129
+            ->method('setUserStatus');
130
+        $this->userStatusService->expects(self::never())
131
+            ->method('findByUserId');
132
+
133
+        $this->service->processCalendarStatus('admin');
134
+    }
135
+
136
+    public function testNoCalendars(): void {
137
+        $user = $this->createConfiguredMock(IUser::class, [
138
+            'getUID' => 'admin',
139
+        ]);
140
+
141
+        $this->userManager->expects(self::once())
142
+            ->method('get')
143
+            ->willReturn($user);
144
+        $this->availabilityCoordinator->expects(self::once())
145
+            ->method('getCurrentOutOfOfficeData')
146
+            ->willReturn(null);
147
+        $this->availabilityCoordinator->expects(self::never())
148
+            ->method('isInEffect');
149
+        $this->cache->expects(self::once())
150
+            ->method('get')
151
+            ->willReturn(null);
152
+        $this->cache->expects(self::once())
153
+            ->method('set');
154
+        $this->calendarManager->expects(self::once())
155
+            ->method('getCalendarsForPrincipal')
156
+            ->willReturn([]);
157
+        $this->calendarManager->expects(self::never())
158
+            ->method('newQuery');
159
+        $this->timeFactory->expects(self::never())
160
+            ->method('getDateTime');
161
+        $this->calendarManager->expects(self::never())
162
+            ->method('searchForPrincipal');
163
+        $this->userStatusService->expects(self::once())
164
+            ->method('revertUserStatus');
165
+        $this->logger->expects(self::once())
166
+            ->method('debug');
167
+        $this->userStatusService->expects(self::never())
168
+            ->method('setUserStatus');
169
+        $this->userStatusService->expects(self::never())
170
+            ->method('findByUserId');
171
+
172
+        $this->service->processCalendarStatus('admin');
173
+    }
174
+
175
+    public function testNoCalendarEvents(): void {
176
+        $user = $this->createConfiguredMock(IUser::class, [
177
+            'getUID' => 'admin',
178
+        ]);
179
+
180
+        $this->userManager->expects(self::once())
181
+            ->method('get')
182
+            ->willReturn($user);
183
+        $this->availabilityCoordinator->expects(self::once())
184
+            ->method('getCurrentOutOfOfficeData')
185
+            ->willReturn(null);
186
+        $this->availabilityCoordinator->expects(self::never())
187
+            ->method('isInEffect');
188
+        $this->cache->expects(self::once())
189
+            ->method('get')
190
+            ->willReturn(null);
191
+        $this->cache->expects(self::once())
192
+            ->method('set');
193
+        $this->calendarManager->expects(self::once())
194
+            ->method('getCalendarsForPrincipal')
195
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
196
+        $this->calendarManager->expects(self::once())
197
+            ->method('newQuery')
198
+            ->willReturn(new CalendarQuery('admin'));
199
+        $this->timeFactory->expects(self::exactly(2))
200
+            ->method('getDateTime')
201
+            ->willReturn(new \DateTime());
202
+        $this->calendarManager->expects(self::once())
203
+            ->method('searchForPrincipal')
204
+            ->willReturn([]);
205
+        $this->userStatusService->expects(self::once())
206
+            ->method('revertUserStatus');
207
+        $this->logger->expects(self::once())
208
+            ->method('debug');
209
+        $this->userStatusService->expects(self::never())
210
+            ->method('setUserStatus');
211
+        $this->userStatusService->expects(self::never())
212
+            ->method('findByUserId');
213
+
214
+        $this->service->processCalendarStatus('admin');
215
+    }
216
+
217
+    public function testCalendarNoEventObjects(): void {
218
+        $user = $this->createConfiguredMock(IUser::class, [
219
+            'getUID' => 'admin',
220
+        ]);
221
+
222
+        $this->userManager->expects(self::once())
223
+            ->method('get')
224
+            ->willReturn($user);
225
+        $this->availabilityCoordinator->expects(self::once())
226
+            ->method('getCurrentOutOfOfficeData')
227
+            ->willReturn(null);
228
+        $this->availabilityCoordinator->expects(self::never())
229
+            ->method('isInEffect');
230
+        $this->cache->expects(self::once())
231
+            ->method('get')
232
+            ->willReturn(null);
233
+        $this->cache->expects(self::once())
234
+            ->method('set');
235
+        $this->calendarManager->expects(self::once())
236
+            ->method('getCalendarsForPrincipal')
237
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
238
+        $this->calendarManager->expects(self::once())
239
+            ->method('newQuery')
240
+            ->willReturn(new CalendarQuery('admin'));
241
+        $this->timeFactory->expects(self::exactly(2))
242
+            ->method('getDateTime')
243
+            ->willReturn(new \DateTime());
244
+        $this->userStatusService->expects(self::once())
245
+            ->method('findByUserId')
246
+            ->willThrowException(new DoesNotExistException(''));
247
+        $this->calendarManager->expects(self::once())
248
+            ->method('searchForPrincipal')
249
+            ->willReturn([['objects' => []]]);
250
+        $this->userStatusService->expects(self::once())
251
+            ->method('revertUserStatus');
252
+        $this->logger->expects(self::once())
253
+            ->method('debug');
254
+        $this->userStatusService->expects(self::never())
255
+            ->method('setUserStatus');
256
+
257
+
258
+        $this->service->processCalendarStatus('admin');
259
+    }
260
+
261
+    public function testCalendarEvent(): void {
262
+        $user = $this->createConfiguredMock(IUser::class, [
263
+            'getUID' => 'admin',
264
+        ]);
265
+
266
+        $this->userManager->expects(self::once())
267
+            ->method('get')
268
+            ->willReturn($user);
269
+        $this->availabilityCoordinator->expects(self::once())
270
+            ->method('getCurrentOutOfOfficeData')
271
+            ->willReturn(null);
272
+        $this->availabilityCoordinator->expects(self::never())
273
+            ->method('isInEffect');
274
+        $this->cache->expects(self::once())
275
+            ->method('get')
276
+            ->willReturn(null);
277
+        $this->cache->expects(self::once())
278
+            ->method('set');
279
+        $this->calendarManager->expects(self::once())
280
+            ->method('getCalendarsForPrincipal')
281
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
282
+        $this->calendarManager->expects(self::once())
283
+            ->method('newQuery')
284
+            ->willReturn(new CalendarQuery('admin'));
285
+        $this->timeFactory->expects(self::exactly(2))
286
+            ->method('getDateTime')
287
+            ->willReturn(new \DateTime());
288
+        $this->userStatusService->expects(self::once())
289
+            ->method('findByUserId')
290
+            ->willThrowException(new DoesNotExistException(''));
291
+        $this->calendarManager->expects(self::once())
292
+            ->method('searchForPrincipal')
293
+            ->willReturn([['objects' => [[]]]]);
294
+        $this->userStatusService->expects(self::never())
295
+            ->method('revertUserStatus');
296
+        $this->logger->expects(self::once())
297
+            ->method('debug');
298
+        $this->userStatusService->expects(self::once())
299
+            ->method('setUserStatus');
300
+
301
+
302
+        $this->service->processCalendarStatus('admin');
303
+    }
304
+
305
+    public function testCallStatus(): void {
306
+        $user = $this->createConfiguredMock(IUser::class, [
307
+            'getUID' => 'admin',
308
+        ]);
309
+
310
+        $this->userManager->expects(self::once())
311
+            ->method('get')
312
+            ->willReturn($user);
313
+        $this->availabilityCoordinator->expects(self::once())
314
+            ->method('getCurrentOutOfOfficeData')
315
+            ->willReturn(null);
316
+        $this->availabilityCoordinator->expects(self::never())
317
+            ->method('isInEffect');
318
+        $this->cache->expects(self::once())
319
+            ->method('get')
320
+            ->willReturn(null);
321
+        $this->cache->expects(self::once())
322
+            ->method('set');
323
+        $this->calendarManager->expects(self::once())
324
+            ->method('getCalendarsForPrincipal')
325
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
326
+        $this->calendarManager->expects(self::once())
327
+            ->method('newQuery')
328
+            ->willReturn(new CalendarQuery('admin'));
329
+        $this->timeFactory->expects(self::exactly(2))
330
+            ->method('getDateTime')
331
+            ->willReturn(new \DateTime());
332
+        $this->calendarManager->expects(self::once())
333
+            ->method('searchForPrincipal')
334
+            ->willReturn([['objects' => [[]]]]);
335
+        $userStatus = new UserStatus();
336
+        $userStatus->setMessageId(IUserStatus::MESSAGE_CALL);
337
+        $userStatus->setStatusTimestamp(123456);
338
+        $this->userStatusService->expects(self::once())
339
+            ->method('findByUserId')
340
+            ->willReturn($userStatus);
341
+        $this->logger->expects(self::once())
342
+            ->method('debug');
343
+        $this->userStatusService->expects(self::never())
344
+            ->method('revertUserStatus');
345
+        $this->userStatusService->expects(self::never())
346
+            ->method('setUserStatus');
347
+
348
+
349
+        $this->service->processCalendarStatus('admin');
350
+    }
351
+
352
+    public function testInvisibleStatus(): void {
353
+        $user = $this->createConfiguredMock(IUser::class, [
354
+            'getUID' => 'admin',
355
+        ]);
356
+
357
+        $this->userManager->expects(self::once())
358
+            ->method('get')
359
+            ->willReturn($user);
360
+        $this->availabilityCoordinator->expects(self::once())
361
+            ->method('getCurrentOutOfOfficeData')
362
+            ->willReturn(null);
363
+        $this->availabilityCoordinator->expects(self::never())
364
+            ->method('isInEffect');
365
+        $this->cache->expects(self::once())
366
+            ->method('get')
367
+            ->willReturn(null);
368
+        $this->cache->expects(self::once())
369
+            ->method('set');
370
+        $this->calendarManager->expects(self::once())
371
+            ->method('getCalendarsForPrincipal')
372
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
373
+        $this->calendarManager->expects(self::once())
374
+            ->method('newQuery')
375
+            ->willReturn(new CalendarQuery('admin'));
376
+        $this->timeFactory->expects(self::exactly(2))
377
+            ->method('getDateTime')
378
+            ->willReturn(new \DateTime());
379
+        $this->calendarManager->expects(self::once())
380
+            ->method('searchForPrincipal')
381
+            ->willReturn([['objects' => [[]]]]);
382
+        $userStatus = new UserStatus();
383
+        $userStatus->setStatus(IUserStatus::INVISIBLE);
384
+        $userStatus->setStatusTimestamp(123456);
385
+        $this->userStatusService->expects(self::once())
386
+            ->method('findByUserId')
387
+            ->willReturn($userStatus);
388
+        $this->logger->expects(self::once())
389
+            ->method('debug');
390
+        $this->userStatusService->expects(self::never())
391
+            ->method('revertUserStatus');
392
+        $this->userStatusService->expects(self::never())
393
+            ->method('setUserStatus');
394
+
395
+
396
+        $this->service->processCalendarStatus('admin');
397
+    }
398
+
399
+    public function testDNDStatus(): void {
400
+        $user = $this->createConfiguredMock(IUser::class, [
401
+            'getUID' => 'admin',
402
+        ]);
403
+
404
+        $this->userManager->expects(self::once())
405
+            ->method('get')
406
+            ->willReturn($user);
407
+        $this->availabilityCoordinator->expects(self::once())
408
+            ->method('getCurrentOutOfOfficeData')
409
+            ->willReturn(null);
410
+        $this->availabilityCoordinator->expects(self::never())
411
+            ->method('isInEffect');
412
+        $this->cache->expects(self::once())
413
+            ->method('get')
414
+            ->willReturn(null);
415
+        $this->cache->expects(self::once())
416
+            ->method('set');
417
+        $this->calendarManager->expects(self::once())
418
+            ->method('getCalendarsForPrincipal')
419
+            ->willReturn([$this->createMock(CalendarImpl::class)]);
420
+        $this->calendarManager->expects(self::once())
421
+            ->method('newQuery')
422
+            ->willReturn(new CalendarQuery('admin'));
423
+        $this->timeFactory->expects(self::exactly(2))
424
+            ->method('getDateTime')
425
+            ->willReturn(new \DateTime());
426
+        $this->calendarManager->expects(self::once())
427
+            ->method('searchForPrincipal')
428
+            ->willReturn([['objects' => [[]]]]);
429
+        $userStatus = new UserStatus();
430
+        $userStatus->setStatus(IUserStatus::DND);
431
+        $userStatus->setStatusTimestamp(123456);
432
+        $this->userStatusService->expects(self::once())
433
+            ->method('findByUserId')
434
+            ->willReturn($userStatus);
435
+        $this->logger->expects(self::once())
436
+            ->method('debug');
437
+        $this->userStatusService->expects(self::never())
438
+            ->method('revertUserStatus');
439
+        $this->userStatusService->expects(self::never())
440
+            ->method('setUserStatus');
441
+
442
+
443
+        $this->service->processCalendarStatus('admin');
444
+    }
445 445
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -32,110 +32,110 @@
 block discarded – undo
32 32
  * @package OCA\DAV\Tests\unit\CalDAV
33 33
  */
34 34
 class PublicCalendarRootTest extends TestCase {
35
-	public const UNIT_TEST_USER = '';
36
-	private CalDavBackend $backend;
37
-	private PublicCalendarRoot $publicCalendarRoot;
38
-	private IL10N&MockObject $l10n;
39
-	private Principal&MockObject $principal;
40
-	protected IUserManager&MockObject $userManager;
41
-	protected IGroupManager&MockObject $groupManager;
42
-	protected IConfig&MockObject $config;
43
-	private ISecureRandom $random;
44
-	private LoggerInterface&MockObject $logger;
45
-
46
-	protected function setUp(): void {
47
-		parent::setUp();
48
-
49
-		$db = Server::get(IDBConnection::class);
50
-		$this->principal = $this->createMock('OCA\DAV\Connector\Sabre\Principal');
51
-		$this->userManager = $this->createMock(IUserManager::class);
52
-		$this->groupManager = $this->createMock(IGroupManager::class);
53
-		$this->random = Server::get(ISecureRandom::class);
54
-		$this->logger = $this->createMock(LoggerInterface::class);
55
-		$dispatcher = $this->createMock(IEventDispatcher::class);
56
-		$config = $this->createMock(IConfig::class);
57
-		$sharingBackend = $this->createMock(\OCA\DAV\CalDAV\Sharing\Backend::class);
58
-
59
-		$this->principal->expects($this->any())->method('getGroupMembership')
60
-			->withAnyParameters()
61
-			->willReturn([]);
62
-
63
-		$this->principal->expects($this->any())->method('getCircleMembership')
64
-			->withAnyParameters()
65
-			->willReturn([]);
66
-
67
-		$this->backend = new CalDavBackend(
68
-			$db,
69
-			$this->principal,
70
-			$this->userManager,
71
-			$this->random,
72
-			$this->logger,
73
-			$dispatcher,
74
-			$config,
75
-			$sharingBackend,
76
-			false,
77
-		);
78
-		$this->l10n = $this->createMock(IL10N::class);
79
-		$this->config = $this->createMock(IConfig::class);
80
-
81
-		$this->publicCalendarRoot = new PublicCalendarRoot($this->backend,
82
-			$this->l10n, $this->config, $this->logger);
83
-	}
84
-
85
-	protected function tearDown(): void {
86
-		parent::tearDown();
87
-
88
-		if (is_null($this->backend)) {
89
-			return;
90
-		}
91
-		$this->principal->expects($this->any())->method('getGroupMembership')
92
-			->withAnyParameters()
93
-			->willReturn([]);
94
-
95
-		$this->principal->expects($this->any())->method('getCircleMembership')
96
-			->withAnyParameters()
97
-			->willReturn([]);
98
-
99
-		$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
100
-		foreach ($books as $book) {
101
-			$this->backend->deleteCalendar($book['id'], true);
102
-		}
103
-	}
104
-
105
-	public function testGetName(): void {
106
-		$name = $this->publicCalendarRoot->getName();
107
-		$this->assertEquals('public-calendars', $name);
108
-	}
109
-
110
-	public function testGetChild(): void {
111
-		$calendar = $this->createPublicCalendar();
112
-
113
-		$publicCalendars = $this->backend->getPublicCalendars();
114
-		$this->assertEquals(1, count($publicCalendars));
115
-		$this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
116
-
117
-		$publicCalendarURI = $publicCalendars[0]['uri'];
118
-
119
-		$calendarResult = $this->publicCalendarRoot->getChild($publicCalendarURI);
120
-		$this->assertEquals($calendar, $calendarResult);
121
-	}
122
-
123
-	public function testGetChildren(): void {
124
-		$this->createPublicCalendar();
125
-		$calendarResults = $this->publicCalendarRoot->getChildren();
126
-		$this->assertSame([], $calendarResults);
127
-	}
128
-
129
-	protected function createPublicCalendar(): Calendar {
130
-		$this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
131
-
132
-		$calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
133
-		$calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
134
-		$publicUri = $calendar->setPublishStatus(true);
135
-
136
-		$calendarInfo = $this->backend->getPublicCalendar($publicUri);
137
-		$calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
138
-
139
-		return $calendar;
140
-	}
35
+    public const UNIT_TEST_USER = '';
36
+    private CalDavBackend $backend;
37
+    private PublicCalendarRoot $publicCalendarRoot;
38
+    private IL10N&MockObject $l10n;
39
+    private Principal&MockObject $principal;
40
+    protected IUserManager&MockObject $userManager;
41
+    protected IGroupManager&MockObject $groupManager;
42
+    protected IConfig&MockObject $config;
43
+    private ISecureRandom $random;
44
+    private LoggerInterface&MockObject $logger;
45
+
46
+    protected function setUp(): void {
47
+        parent::setUp();
48
+
49
+        $db = Server::get(IDBConnection::class);
50
+        $this->principal = $this->createMock('OCA\DAV\Connector\Sabre\Principal');
51
+        $this->userManager = $this->createMock(IUserManager::class);
52
+        $this->groupManager = $this->createMock(IGroupManager::class);
53
+        $this->random = Server::get(ISecureRandom::class);
54
+        $this->logger = $this->createMock(LoggerInterface::class);
55
+        $dispatcher = $this->createMock(IEventDispatcher::class);
56
+        $config = $this->createMock(IConfig::class);
57
+        $sharingBackend = $this->createMock(\OCA\DAV\CalDAV\Sharing\Backend::class);
58
+
59
+        $this->principal->expects($this->any())->method('getGroupMembership')
60
+            ->withAnyParameters()
61
+            ->willReturn([]);
62
+
63
+        $this->principal->expects($this->any())->method('getCircleMembership')
64
+            ->withAnyParameters()
65
+            ->willReturn([]);
66
+
67
+        $this->backend = new CalDavBackend(
68
+            $db,
69
+            $this->principal,
70
+            $this->userManager,
71
+            $this->random,
72
+            $this->logger,
73
+            $dispatcher,
74
+            $config,
75
+            $sharingBackend,
76
+            false,
77
+        );
78
+        $this->l10n = $this->createMock(IL10N::class);
79
+        $this->config = $this->createMock(IConfig::class);
80
+
81
+        $this->publicCalendarRoot = new PublicCalendarRoot($this->backend,
82
+            $this->l10n, $this->config, $this->logger);
83
+    }
84
+
85
+    protected function tearDown(): void {
86
+        parent::tearDown();
87
+
88
+        if (is_null($this->backend)) {
89
+            return;
90
+        }
91
+        $this->principal->expects($this->any())->method('getGroupMembership')
92
+            ->withAnyParameters()
93
+            ->willReturn([]);
94
+
95
+        $this->principal->expects($this->any())->method('getCircleMembership')
96
+            ->withAnyParameters()
97
+            ->willReturn([]);
98
+
99
+        $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
100
+        foreach ($books as $book) {
101
+            $this->backend->deleteCalendar($book['id'], true);
102
+        }
103
+    }
104
+
105
+    public function testGetName(): void {
106
+        $name = $this->publicCalendarRoot->getName();
107
+        $this->assertEquals('public-calendars', $name);
108
+    }
109
+
110
+    public function testGetChild(): void {
111
+        $calendar = $this->createPublicCalendar();
112
+
113
+        $publicCalendars = $this->backend->getPublicCalendars();
114
+        $this->assertEquals(1, count($publicCalendars));
115
+        $this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
116
+
117
+        $publicCalendarURI = $publicCalendars[0]['uri'];
118
+
119
+        $calendarResult = $this->publicCalendarRoot->getChild($publicCalendarURI);
120
+        $this->assertEquals($calendar, $calendarResult);
121
+    }
122
+
123
+    public function testGetChildren(): void {
124
+        $this->createPublicCalendar();
125
+        $calendarResults = $this->publicCalendarRoot->getChildren();
126
+        $this->assertSame([], $calendarResults);
127
+    }
128
+
129
+    protected function createPublicCalendar(): Calendar {
130
+        $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
131
+
132
+        $calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
133
+        $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
134
+        $publicUri = $calendar->setPublishStatus(true);
135
+
136
+        $calendarInfo = $this->backend->getPublicCalendar($publicUri);
137
+        $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
138
+
139
+        return $calendar;
140
+    }
141 141
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/CachedSubscriptionProviderTest.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -17,56 +17,56 @@
 block discarded – undo
17 17
 
18 18
 class CachedSubscriptionProviderTest extends TestCase {
19 19
 
20
-	private CalDavBackend&MockObject $backend;
21
-	private CachedSubscriptionProvider $provider;
20
+    private CalDavBackend&MockObject $backend;
21
+    private CachedSubscriptionProvider $provider;
22 22
 
23
-	protected function setUp(): void {
24
-		parent::setUp();
23
+    protected function setUp(): void {
24
+        parent::setUp();
25 25
 
26
-		$this->backend = $this->createMock(CalDavBackend::class);
27
-		$this->backend
28
-			->expects(self::once())
29
-			->method('getSubscriptionsForUser')
30
-			->with('user-principal-123')
31
-			->willReturn([
32
-				[
33
-					'id' => 'subscription-1',
34
-					'uri' => 'subscription-1',
35
-					'principaluris' => 'user-principal-123',
36
-					'source' => 'https://localhost/subscription-1',
37
-					// A subscription array has actually more properties.
38
-				],
39
-				[
40
-					'id' => 'subscription-2',
41
-					'uri' => 'subscription-2',
42
-					'principaluri' => 'user-principal-123',
43
-					'source' => 'https://localhost/subscription-2',
44
-					// A subscription array has actually more properties.
45
-				]
46
-			]);
26
+        $this->backend = $this->createMock(CalDavBackend::class);
27
+        $this->backend
28
+            ->expects(self::once())
29
+            ->method('getSubscriptionsForUser')
30
+            ->with('user-principal-123')
31
+            ->willReturn([
32
+                [
33
+                    'id' => 'subscription-1',
34
+                    'uri' => 'subscription-1',
35
+                    'principaluris' => 'user-principal-123',
36
+                    'source' => 'https://localhost/subscription-1',
37
+                    // A subscription array has actually more properties.
38
+                ],
39
+                [
40
+                    'id' => 'subscription-2',
41
+                    'uri' => 'subscription-2',
42
+                    'principaluri' => 'user-principal-123',
43
+                    'source' => 'https://localhost/subscription-2',
44
+                    // A subscription array has actually more properties.
45
+                ]
46
+            ]);
47 47
 
48
-		$this->provider = new CachedSubscriptionProvider($this->backend);
49
-	}
48
+        $this->provider = new CachedSubscriptionProvider($this->backend);
49
+    }
50 50
 
51
-	public function testGetCalendars(): void {
52
-		$calendars = $this->provider->getCalendars(
53
-			'user-principal-123',
54
-			[]
55
-		);
51
+    public function testGetCalendars(): void {
52
+        $calendars = $this->provider->getCalendars(
53
+            'user-principal-123',
54
+            []
55
+        );
56 56
 
57
-		$this->assertCount(2, $calendars);
58
-		$this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[0]);
59
-		$this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[1]);
60
-	}
57
+        $this->assertCount(2, $calendars);
58
+        $this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[0]);
59
+        $this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[1]);
60
+    }
61 61
 
62
-	public function testGetCalendarsFilterByUri(): void {
63
-		$calendars = $this->provider->getCalendars(
64
-			'user-principal-123',
65
-			['subscription-1']
66
-		);
62
+    public function testGetCalendarsFilterByUri(): void {
63
+        $calendars = $this->provider->getCalendars(
64
+            'user-principal-123',
65
+            ['subscription-1']
66
+        );
67 67
 
68
-		$this->assertCount(1, $calendars);
69
-		$this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[0]);
70
-		$this->assertEquals('subscription-1', $calendars[0]->getUri());
71
-	}
68
+        $this->assertCount(1, $calendars);
69
+        $this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[0]);
70
+        $this->assertEquals('subscription-1', $calendars[0]->getUri());
71
+    }
72 72
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php 1 patch
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -17,205 +17,205 @@
 block discarded – undo
17 17
 use Test\TestCase;
18 18
 
19 19
 class EnablePluginTest extends TestCase {
20
-	protected \Sabre\DAV\Server&MockObject $server;
21
-	protected IConfig&MockObject $config;
22
-	protected BirthdayService&MockObject $birthdayService;
23
-	protected IUser&MockObject $user;
24
-	protected EnablePlugin $plugin;
20
+    protected \Sabre\DAV\Server&MockObject $server;
21
+    protected IConfig&MockObject $config;
22
+    protected BirthdayService&MockObject $birthdayService;
23
+    protected IUser&MockObject $user;
24
+    protected EnablePlugin $plugin;
25 25
 
26
-	protected $request;
26
+    protected $request;
27 27
 
28
-	protected $response;
28
+    protected $response;
29 29
 
30
-	protected function setUp(): void {
31
-		parent::setUp();
30
+    protected function setUp(): void {
31
+        parent::setUp();
32 32
 
33
-		$this->server = $this->createMock(\Sabre\DAV\Server::class);
34
-		$this->server->tree = $this->createMock(\Sabre\DAV\Tree::class);
35
-		$this->server->httpResponse = $this->createMock(\Sabre\HTTP\Response::class);
36
-		$this->server->xml = $this->createMock(\Sabre\DAV\Xml\Service::class);
33
+        $this->server = $this->createMock(\Sabre\DAV\Server::class);
34
+        $this->server->tree = $this->createMock(\Sabre\DAV\Tree::class);
35
+        $this->server->httpResponse = $this->createMock(\Sabre\HTTP\Response::class);
36
+        $this->server->xml = $this->createMock(\Sabre\DAV\Xml\Service::class);
37 37
 
38
-		$this->config = $this->createMock(IConfig::class);
39
-		$this->birthdayService = $this->createMock(BirthdayService::class);
40
-		$this->user = $this->createMock(IUser::class);
38
+        $this->config = $this->createMock(IConfig::class);
39
+        $this->birthdayService = $this->createMock(BirthdayService::class);
40
+        $this->user = $this->createMock(IUser::class);
41 41
 
42
-		$this->plugin = new EnablePlugin($this->config, $this->birthdayService, $this->user);
43
-		$this->plugin->initialize($this->server);
42
+        $this->plugin = new EnablePlugin($this->config, $this->birthdayService, $this->user);
43
+        $this->plugin->initialize($this->server);
44 44
 
45
-		$this->request = $this->createMock(\Sabre\HTTP\RequestInterface::class);
46
-		$this->response = $this->createMock(\Sabre\HTTP\ResponseInterface::class);
47
-	}
45
+        $this->request = $this->createMock(\Sabre\HTTP\RequestInterface::class);
46
+        $this->response = $this->createMock(\Sabre\HTTP\ResponseInterface::class);
47
+    }
48 48
 
49
-	public function testGetFeatures(): void {
50
-		$this->assertEquals(['nc-enable-birthday-calendar'], $this->plugin->getFeatures());
51
-	}
49
+    public function testGetFeatures(): void {
50
+        $this->assertEquals(['nc-enable-birthday-calendar'], $this->plugin->getFeatures());
51
+    }
52 52
 
53
-	public function testGetName(): void {
54
-		$this->assertEquals('nc-enable-birthday-calendar', $this->plugin->getPluginName());
55
-	}
53
+    public function testGetName(): void {
54
+        $this->assertEquals('nc-enable-birthday-calendar', $this->plugin->getPluginName());
55
+    }
56 56
 
57
-	public function testInitialize(): void {
58
-		$server = $this->createMock(\Sabre\DAV\Server::class);
57
+    public function testInitialize(): void {
58
+        $server = $this->createMock(\Sabre\DAV\Server::class);
59 59
 
60
-		$plugin = new EnablePlugin($this->config, $this->birthdayService, $this->user);
60
+        $plugin = new EnablePlugin($this->config, $this->birthdayService, $this->user);
61 61
 
62
-		$server->expects($this->once())
63
-			->method('on')
64
-			->with('method:POST', [$plugin, 'httpPost']);
62
+        $server->expects($this->once())
63
+            ->method('on')
64
+            ->with('method:POST', [$plugin, 'httpPost']);
65 65
 
66
-		$plugin->initialize($server);
67
-	}
66
+        $plugin->initialize($server);
67
+    }
68 68
 
69
-	public function testHttpPostNoCalendarHome(): void {
70
-		$calendar = $this->createMock(Calendar::class);
69
+    public function testHttpPostNoCalendarHome(): void {
70
+        $calendar = $this->createMock(Calendar::class);
71 71
 
72
-		$this->server->expects($this->once())
73
-			->method('getRequestUri')
74
-			->willReturn('/bar/foo');
75
-		$this->server->tree->expects($this->once())
76
-			->method('getNodeForPath')
77
-			->with('/bar/foo')
78
-			->willReturn($calendar);
72
+        $this->server->expects($this->once())
73
+            ->method('getRequestUri')
74
+            ->willReturn('/bar/foo');
75
+        $this->server->tree->expects($this->once())
76
+            ->method('getNodeForPath')
77
+            ->with('/bar/foo')
78
+            ->willReturn($calendar);
79 79
 
80
-		$this->config->expects($this->never())
81
-			->method('setUserValue');
80
+        $this->config->expects($this->never())
81
+            ->method('setUserValue');
82 82
 
83
-		$this->birthdayService->expects($this->never())
84
-			->method('syncUser');
83
+        $this->birthdayService->expects($this->never())
84
+            ->method('syncUser');
85 85
 
86
-		$this->plugin->httpPost($this->request, $this->response);
87
-	}
86
+        $this->plugin->httpPost($this->request, $this->response);
87
+    }
88 88
 
89
-	public function testHttpPostWrongRequest(): void {
90
-		$calendarHome = $this->createMock(CalendarHome::class);
89
+    public function testHttpPostWrongRequest(): void {
90
+        $calendarHome = $this->createMock(CalendarHome::class);
91 91
 
92
-		$this->server->expects($this->once())
93
-			->method('getRequestUri')
94
-			->willReturn('/bar/foo');
95
-		$this->server->tree->expects($this->once())
96
-			->method('getNodeForPath')
97
-			->with('/bar/foo')
98
-			->willReturn($calendarHome);
92
+        $this->server->expects($this->once())
93
+            ->method('getRequestUri')
94
+            ->willReturn('/bar/foo');
95
+        $this->server->tree->expects($this->once())
96
+            ->method('getNodeForPath')
97
+            ->with('/bar/foo')
98
+            ->willReturn($calendarHome);
99 99
 
100
-		$this->request->expects($this->once())
101
-			->method('getBodyAsString')
102
-			->willReturn('<nc:disable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
100
+        $this->request->expects($this->once())
101
+            ->method('getBodyAsString')
102
+            ->willReturn('<nc:disable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
103 103
 
104
-		$this->request->expects($this->once())
105
-			->method('getUrl')
106
-			->willReturn('url_abc');
104
+        $this->request->expects($this->once())
105
+            ->method('getUrl')
106
+            ->willReturn('url_abc');
107 107
 
108
-		$this->server->xml->expects($this->once())
109
-			->method('parse')
110
-			->willReturnCallback(function ($requestBody, $url, &$documentType): void {
111
-				$documentType = '{http://nextcloud.com/ns}disable-birthday-calendar';
112
-			});
108
+        $this->server->xml->expects($this->once())
109
+            ->method('parse')
110
+            ->willReturnCallback(function ($requestBody, $url, &$documentType): void {
111
+                $documentType = '{http://nextcloud.com/ns}disable-birthday-calendar';
112
+            });
113 113
 
114
-		$this->config->expects($this->never())
115
-			->method('setUserValue');
114
+        $this->config->expects($this->never())
115
+            ->method('setUserValue');
116 116
 
117
-		$this->birthdayService->expects($this->never())
118
-			->method('syncUser');
117
+        $this->birthdayService->expects($this->never())
118
+            ->method('syncUser');
119 119
 
120
-		$this->plugin->httpPost($this->request, $this->response);
121
-	}
120
+        $this->plugin->httpPost($this->request, $this->response);
121
+    }
122 122
 
123
-	public function testHttpPostNotAuthorized(): void {
124
-		$calendarHome = $this->createMock(CalendarHome::class);
123
+    public function testHttpPostNotAuthorized(): void {
124
+        $calendarHome = $this->createMock(CalendarHome::class);
125 125
 
126
-		$this->server->expects($this->once())
127
-			->method('getRequestUri')
128
-			->willReturn('/bar/foo');
129
-		$this->server->tree->expects($this->once())
130
-			->method('getNodeForPath')
131
-			->with('/bar/foo')
132
-			->willReturn($calendarHome);
126
+        $this->server->expects($this->once())
127
+            ->method('getRequestUri')
128
+            ->willReturn('/bar/foo');
129
+        $this->server->tree->expects($this->once())
130
+            ->method('getNodeForPath')
131
+            ->with('/bar/foo')
132
+            ->willReturn($calendarHome);
133 133
 
134
-		$calendarHome->expects($this->once())
135
-			->method('getOwner')
136
-			->willReturn('principals/users/BlaBlub');
134
+        $calendarHome->expects($this->once())
135
+            ->method('getOwner')
136
+            ->willReturn('principals/users/BlaBlub');
137 137
 
138
-		$this->request->expects($this->once())
139
-			->method('getBodyAsString')
140
-			->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
138
+        $this->request->expects($this->once())
139
+            ->method('getBodyAsString')
140
+            ->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
141 141
 
142
-		$this->request->expects($this->once())
143
-			->method('getUrl')
144
-			->willReturn('url_abc');
142
+        $this->request->expects($this->once())
143
+            ->method('getUrl')
144
+            ->willReturn('url_abc');
145 145
 
146
-		$this->server->xml->expects($this->once())
147
-			->method('parse')
148
-			->willReturnCallback(function ($requestBody, $url, &$documentType): void {
149
-				$documentType = '{http://nextcloud.com/ns}enable-birthday-calendar';
150
-			});
146
+        $this->server->xml->expects($this->once())
147
+            ->method('parse')
148
+            ->willReturnCallback(function ($requestBody, $url, &$documentType): void {
149
+                $documentType = '{http://nextcloud.com/ns}enable-birthday-calendar';
150
+            });
151 151
 
152
-		$this->user->expects(self::once())
153
-			->method('getUID')
154
-			->willReturn('admin');
152
+        $this->user->expects(self::once())
153
+            ->method('getUID')
154
+            ->willReturn('admin');
155 155
 
156
-		$this->server->httpResponse->expects($this->once())
157
-			->method('setStatus')
158
-			->with(403);
156
+        $this->server->httpResponse->expects($this->once())
157
+            ->method('setStatus')
158
+            ->with(403);
159 159
 
160
-		$this->config->expects($this->never())
161
-			->method('setUserValue');
160
+        $this->config->expects($this->never())
161
+            ->method('setUserValue');
162 162
 
163
-		$this->birthdayService->expects($this->never())
164
-			->method('syncUser');
163
+        $this->birthdayService->expects($this->never())
164
+            ->method('syncUser');
165 165
 
166 166
 
167
-		$result = $this->plugin->httpPost($this->request, $this->response);
167
+        $result = $this->plugin->httpPost($this->request, $this->response);
168 168
 
169
-		$this->assertEquals(false, $result);
170
-	}
169
+        $this->assertEquals(false, $result);
170
+    }
171 171
 
172
-	public function testHttpPost(): void {
173
-		$calendarHome = $this->createMock(CalendarHome::class);
172
+    public function testHttpPost(): void {
173
+        $calendarHome = $this->createMock(CalendarHome::class);
174 174
 
175
-		$this->server->expects($this->once())
176
-			->method('getRequestUri')
177
-			->willReturn('/bar/foo');
178
-		$this->server->tree->expects($this->once())
179
-			->method('getNodeForPath')
180
-			->with('/bar/foo')
181
-			->willReturn($calendarHome);
175
+        $this->server->expects($this->once())
176
+            ->method('getRequestUri')
177
+            ->willReturn('/bar/foo');
178
+        $this->server->tree->expects($this->once())
179
+            ->method('getNodeForPath')
180
+            ->with('/bar/foo')
181
+            ->willReturn($calendarHome);
182 182
 
183
-		$calendarHome->expects($this->once())
184
-			->method('getOwner')
185
-			->willReturn('principals/users/BlaBlub');
183
+        $calendarHome->expects($this->once())
184
+            ->method('getOwner')
185
+            ->willReturn('principals/users/BlaBlub');
186 186
 
187
-		$this->request->expects($this->once())
188
-			->method('getBodyAsString')
189
-			->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
187
+        $this->request->expects($this->once())
188
+            ->method('getBodyAsString')
189
+            ->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
190 190
 
191
-		$this->request->expects($this->once())
192
-			->method('getUrl')
193
-			->willReturn('url_abc');
191
+        $this->request->expects($this->once())
192
+            ->method('getUrl')
193
+            ->willReturn('url_abc');
194 194
 
195
-		$this->server->xml->expects($this->once())
196
-			->method('parse')
197
-			->willReturnCallback(function ($requestBody, $url, &$documentType): void {
198
-				$documentType = '{http://nextcloud.com/ns}enable-birthday-calendar';
199
-			});
195
+        $this->server->xml->expects($this->once())
196
+            ->method('parse')
197
+            ->willReturnCallback(function ($requestBody, $url, &$documentType): void {
198
+                $documentType = '{http://nextcloud.com/ns}enable-birthday-calendar';
199
+            });
200 200
 
201
-		$this->user->expects(self::exactly(3))
202
-			->method('getUID')
203
-			->willReturn('BlaBlub');
201
+        $this->user->expects(self::exactly(3))
202
+            ->method('getUID')
203
+            ->willReturn('BlaBlub');
204 204
 
205
-		$this->config->expects($this->once())
206
-			->method('setUserValue')
207
-			->with('BlaBlub', 'dav', 'generateBirthdayCalendar', 'yes');
205
+        $this->config->expects($this->once())
206
+            ->method('setUserValue')
207
+            ->with('BlaBlub', 'dav', 'generateBirthdayCalendar', 'yes');
208 208
 
209
-		$this->birthdayService->expects($this->once())
210
-			->method('syncUser')
211
-			->with('BlaBlub');
209
+        $this->birthdayService->expects($this->once())
210
+            ->method('syncUser')
211
+            ->with('BlaBlub');
212 212
 
213
-		$this->server->httpResponse->expects($this->once())
214
-			->method('setStatus')
215
-			->with(204);
213
+        $this->server->httpResponse->expects($this->once())
214
+            ->method('setStatus')
215
+            ->with(204);
216 216
 
217
-		$result = $this->plugin->httpPost($this->request, $this->response);
217
+        $result = $this->plugin->httpPost($this->request, $this->response);
218 218
 
219
-		$this->assertEquals(false, $result);
220
-	}
219
+        $this->assertEquals(false, $result);
220
+    }
221 221
 }
Please login to merge, or discard this patch.