Completed
Push — master ( ca4819...0ca6f7 )
by Joas
28:28 queued 14s
created
apps/dav/tests/unit/CalDAV/WebcalCaching/ConnectionTest.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -20,159 +20,159 @@
 block discarded – undo
20 20
 
21 21
 class ConnectionTest extends TestCase {
22 22
 
23
-	private IClientService&MockObject $clientService;
24
-	private IAppConfig&MockObject $config;
25
-	private LoggerInterface&MockObject $logger;
26
-	private Connection $connection;
27
-
28
-	public function setUp(): void {
29
-		$this->clientService = $this->createMock(IClientService::class);
30
-		$this->config = $this->createMock(IAppConfig::class);
31
-		$this->logger = $this->createMock(LoggerInterface::class);
32
-		$this->connection = new Connection($this->clientService, $this->config, $this->logger);
33
-	}
34
-
35
-	/**
36
-	 * @dataProvider runLocalURLDataProvider
37
-	 */
38
-	public function testLocalUrl($source): void {
39
-		$subscription = [
40
-			'id' => 42,
41
-			'uri' => 'sub123',
42
-			'refreshreate' => 'P1H',
43
-			'striptodos' => 1,
44
-			'stripalarms' => 1,
45
-			'stripattachments' => 1,
46
-			'source' => $source,
47
-			'lastmodified' => 0,
48
-		];
49
-
50
-		$client = $this->createMock(IClient::class);
51
-		$this->clientService->expects(self::once())
52
-			->method('newClient')
53
-			->with()
54
-			->willReturn($client);
55
-
56
-		$this->config->expects(self::once())
57
-			->method('getValueString')
58
-			->with('dav', 'webcalAllowLocalAccess', 'no')
59
-			->willReturn('no');
60
-
61
-		$localServerException = new LocalServerException();
62
-		$client->expects(self::once())
63
-			->method('get')
64
-			->willThrowException($localServerException);
65
-		$this->logger->expects(self::once())
66
-			->method('warning')
67
-			->with('Subscription 42 was not refreshed because it violates local access rules', ['exception' => $localServerException]);
68
-
69
-		$this->connection->queryWebcalFeed($subscription);
70
-	}
71
-
72
-	public function testInvalidUrl(): void {
73
-		$subscription = [
74
-			'id' => 42,
75
-			'uri' => 'sub123',
76
-			'refreshreate' => 'P1H',
77
-			'striptodos' => 1,
78
-			'stripalarms' => 1,
79
-			'stripattachments' => 1,
80
-			'source' => '!@#$',
81
-			'lastmodified' => 0,
82
-		];
83
-
84
-		$client = $this->createMock(IClient::class);
85
-		$this->config->expects(self::never())
86
-			->method('getValueString');
87
-		$client->expects(self::never())
88
-			->method('get');
89
-
90
-		$this->connection->queryWebcalFeed($subscription);
91
-
92
-	}
93
-
94
-	/**
95
-	 * @param string $result
96
-	 * @param string $contentType
97
-	 * @dataProvider urlDataProvider
98
-	 */
99
-	public function testConnection(string $url, string $result, string $contentType): void {
100
-		$client = $this->createMock(IClient::class);
101
-		$response = $this->createMock(IResponse::class);
102
-		$subscription = [
103
-			'id' => 42,
104
-			'uri' => 'sub123',
105
-			'refreshreate' => 'P1H',
106
-			'striptodos' => 1,
107
-			'stripalarms' => 1,
108
-			'stripattachments' => 1,
109
-			'source' => $url,
110
-			'lastmodified' => 0,
111
-		];
112
-
113
-		$this->clientService->expects($this->once())
114
-			->method('newClient')
115
-			->with()
116
-			->willReturn($client);
117
-
118
-		$this->config->expects($this->once())
119
-			->method('getValueString')
120
-			->with('dav', 'webcalAllowLocalAccess', 'no')
121
-			->willReturn('no');
122
-
123
-		$client->expects($this->once())
124
-			->method('get')
125
-			->with('https://foo.bar/bla2')
126
-			->willReturn($response);
127
-
128
-		$response->expects($this->once())
129
-			->method('getBody')
130
-			->with()
131
-			->willReturn($result);
132
-		$response->expects($this->once())
133
-			->method('getHeader')
134
-			->with('Content-Type')
135
-			->willReturn($contentType);
136
-
137
-		$this->connection->queryWebcalFeed($subscription);
138
-	}
139
-
140
-	public static function runLocalURLDataProvider(): array {
141
-		return [
142
-			['localhost/foo.bar'],
143
-			['localHost/foo.bar'],
144
-			['random-host/foo.bar'],
145
-			['[::1]/bla.blub'],
146
-			['[::]/bla.blub'],
147
-			['192.168.0.1'],
148
-			['172.16.42.1'],
149
-			['[fdf8:f53b:82e4::53]/secret.ics'],
150
-			['[fe80::200:5aee:feaa:20a2]/secret.ics'],
151
-			['[0:0:0:0:0:0:10.0.0.1]/secret.ics'],
152
-			['[0:0:0:0:0:ffff:127.0.0.0]/secret.ics'],
153
-			['10.0.0.1'],
154
-			['another-host.local'],
155
-			['service.localhost'],
156
-		];
157
-	}
158
-
159
-	public static function urlDataProvider(): array {
160
-		return [
161
-			[
162
-				'https://foo.bar/bla2',
163
-				"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
164
-				'text/calendar;charset=utf8',
165
-			],
166
-			[
167
-				'https://foo.bar/bla2',
168
-				'["vcalendar",[["prodid",{},"text","-//Example Corp.//Example Client//EN"],["version",{},"text","2.0"]],[["vtimezone",[["last-modified",{},"date-time","2004-01-10T03:28:45Z"],["tzid",{},"text","US/Eastern"]],[["daylight",[["dtstart",{},"date-time","2000-04-04T02:00:00"],["rrule",{},"recur",{"freq":"YEARLY","byday":"1SU","bymonth":4}],["tzname",{},"text","EDT"],["tzoffsetfrom",{},"utc-offset","-05:00"],["tzoffsetto",{},"utc-offset","-04:00"]],[]],["standard",[["dtstart",{},"date-time","2000-10-26T02:00:00"],["rrule",{},"recur",{"freq":"YEARLY","byday":"1SU","bymonth":10}],["tzname",{},"text","EST"],["tzoffsetfrom",{},"utc-offset","-04:00"],["tzoffsetto",{},"utc-offset","-05:00"]],[]]]],["vevent",[["dtstamp",{},"date-time","2006-02-06T00:11:21Z"],["dtstart",{"tzid":"US/Eastern"},"date-time","2006-01-02T14:00:00"],["duration",{},"duration","PT1H"],["recurrence-id",{"tzid":"US/Eastern"},"date-time","2006-01-04T12:00:00"],["summary",{},"text","Event #2"],["uid",{},"text","12345"]],[]]]]',
169
-				'application/calendar+json',
170
-			],
171
-			[
172
-				'https://foo.bar/bla2',
173
-				'<?xml version="1.0" encoding="utf-8" ?><icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0"><vcalendar><properties><prodid><text>-//Example Inc.//Example Client//EN</text></prodid><version><text>2.0</text></version></properties><components><vevent><properties><dtstamp><date-time>2006-02-06T00:11:21Z</date-time></dtstamp><dtstart><parameters><tzid><text>US/Eastern</text></tzid></parameters><date-time>2006-01-04T14:00:00</date-time></dtstart><duration><duration>PT1H</duration></duration><recurrence-id><parameters><tzid><text>US/Eastern</text></tzid></parameters><date-time>2006-01-04T12:00:00</date-time></recurrence-id><summary><text>Event #2 bis</text></summary><uid><text>12345</text></uid></properties></vevent></components></vcalendar></icalendar>',
174
-				'application/calendar+xml',
175
-			],
176
-		];
177
-	}
23
+    private IClientService&MockObject $clientService;
24
+    private IAppConfig&MockObject $config;
25
+    private LoggerInterface&MockObject $logger;
26
+    private Connection $connection;
27
+
28
+    public function setUp(): void {
29
+        $this->clientService = $this->createMock(IClientService::class);
30
+        $this->config = $this->createMock(IAppConfig::class);
31
+        $this->logger = $this->createMock(LoggerInterface::class);
32
+        $this->connection = new Connection($this->clientService, $this->config, $this->logger);
33
+    }
34
+
35
+    /**
36
+     * @dataProvider runLocalURLDataProvider
37
+     */
38
+    public function testLocalUrl($source): void {
39
+        $subscription = [
40
+            'id' => 42,
41
+            'uri' => 'sub123',
42
+            'refreshreate' => 'P1H',
43
+            'striptodos' => 1,
44
+            'stripalarms' => 1,
45
+            'stripattachments' => 1,
46
+            'source' => $source,
47
+            'lastmodified' => 0,
48
+        ];
49
+
50
+        $client = $this->createMock(IClient::class);
51
+        $this->clientService->expects(self::once())
52
+            ->method('newClient')
53
+            ->with()
54
+            ->willReturn($client);
55
+
56
+        $this->config->expects(self::once())
57
+            ->method('getValueString')
58
+            ->with('dav', 'webcalAllowLocalAccess', 'no')
59
+            ->willReturn('no');
60
+
61
+        $localServerException = new LocalServerException();
62
+        $client->expects(self::once())
63
+            ->method('get')
64
+            ->willThrowException($localServerException);
65
+        $this->logger->expects(self::once())
66
+            ->method('warning')
67
+            ->with('Subscription 42 was not refreshed because it violates local access rules', ['exception' => $localServerException]);
68
+
69
+        $this->connection->queryWebcalFeed($subscription);
70
+    }
71
+
72
+    public function testInvalidUrl(): void {
73
+        $subscription = [
74
+            'id' => 42,
75
+            'uri' => 'sub123',
76
+            'refreshreate' => 'P1H',
77
+            'striptodos' => 1,
78
+            'stripalarms' => 1,
79
+            'stripattachments' => 1,
80
+            'source' => '!@#$',
81
+            'lastmodified' => 0,
82
+        ];
83
+
84
+        $client = $this->createMock(IClient::class);
85
+        $this->config->expects(self::never())
86
+            ->method('getValueString');
87
+        $client->expects(self::never())
88
+            ->method('get');
89
+
90
+        $this->connection->queryWebcalFeed($subscription);
91
+
92
+    }
93
+
94
+    /**
95
+     * @param string $result
96
+     * @param string $contentType
97
+     * @dataProvider urlDataProvider
98
+     */
99
+    public function testConnection(string $url, string $result, string $contentType): void {
100
+        $client = $this->createMock(IClient::class);
101
+        $response = $this->createMock(IResponse::class);
102
+        $subscription = [
103
+            'id' => 42,
104
+            'uri' => 'sub123',
105
+            'refreshreate' => 'P1H',
106
+            'striptodos' => 1,
107
+            'stripalarms' => 1,
108
+            'stripattachments' => 1,
109
+            'source' => $url,
110
+            'lastmodified' => 0,
111
+        ];
112
+
113
+        $this->clientService->expects($this->once())
114
+            ->method('newClient')
115
+            ->with()
116
+            ->willReturn($client);
117
+
118
+        $this->config->expects($this->once())
119
+            ->method('getValueString')
120
+            ->with('dav', 'webcalAllowLocalAccess', 'no')
121
+            ->willReturn('no');
122
+
123
+        $client->expects($this->once())
124
+            ->method('get')
125
+            ->with('https://foo.bar/bla2')
126
+            ->willReturn($response);
127
+
128
+        $response->expects($this->once())
129
+            ->method('getBody')
130
+            ->with()
131
+            ->willReturn($result);
132
+        $response->expects($this->once())
133
+            ->method('getHeader')
134
+            ->with('Content-Type')
135
+            ->willReturn($contentType);
136
+
137
+        $this->connection->queryWebcalFeed($subscription);
138
+    }
139
+
140
+    public static function runLocalURLDataProvider(): array {
141
+        return [
142
+            ['localhost/foo.bar'],
143
+            ['localHost/foo.bar'],
144
+            ['random-host/foo.bar'],
145
+            ['[::1]/bla.blub'],
146
+            ['[::]/bla.blub'],
147
+            ['192.168.0.1'],
148
+            ['172.16.42.1'],
149
+            ['[fdf8:f53b:82e4::53]/secret.ics'],
150
+            ['[fe80::200:5aee:feaa:20a2]/secret.ics'],
151
+            ['[0:0:0:0:0:0:10.0.0.1]/secret.ics'],
152
+            ['[0:0:0:0:0:ffff:127.0.0.0]/secret.ics'],
153
+            ['10.0.0.1'],
154
+            ['another-host.local'],
155
+            ['service.localhost'],
156
+        ];
157
+    }
158
+
159
+    public static function urlDataProvider(): array {
160
+        return [
161
+            [
162
+                'https://foo.bar/bla2',
163
+                "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
164
+                'text/calendar;charset=utf8',
165
+            ],
166
+            [
167
+                'https://foo.bar/bla2',
168
+                '["vcalendar",[["prodid",{},"text","-//Example Corp.//Example Client//EN"],["version",{},"text","2.0"]],[["vtimezone",[["last-modified",{},"date-time","2004-01-10T03:28:45Z"],["tzid",{},"text","US/Eastern"]],[["daylight",[["dtstart",{},"date-time","2000-04-04T02:00:00"],["rrule",{},"recur",{"freq":"YEARLY","byday":"1SU","bymonth":4}],["tzname",{},"text","EDT"],["tzoffsetfrom",{},"utc-offset","-05:00"],["tzoffsetto",{},"utc-offset","-04:00"]],[]],["standard",[["dtstart",{},"date-time","2000-10-26T02:00:00"],["rrule",{},"recur",{"freq":"YEARLY","byday":"1SU","bymonth":10}],["tzname",{},"text","EST"],["tzoffsetfrom",{},"utc-offset","-04:00"],["tzoffsetto",{},"utc-offset","-05:00"]],[]]]],["vevent",[["dtstamp",{},"date-time","2006-02-06T00:11:21Z"],["dtstart",{"tzid":"US/Eastern"},"date-time","2006-01-02T14:00:00"],["duration",{},"duration","PT1H"],["recurrence-id",{"tzid":"US/Eastern"},"date-time","2006-01-04T12:00:00"],["summary",{},"text","Event #2"],["uid",{},"text","12345"]],[]]]]',
169
+                'application/calendar+json',
170
+            ],
171
+            [
172
+                'https://foo.bar/bla2',
173
+                '<?xml version="1.0" encoding="utf-8" ?><icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0"><vcalendar><properties><prodid><text>-//Example Inc.//Example Client//EN</text></prodid><version><text>2.0</text></version></properties><components><vevent><properties><dtstamp><date-time>2006-02-06T00:11:21Z</date-time></dtstamp><dtstart><parameters><tzid><text>US/Eastern</text></tzid></parameters><date-time>2006-01-04T14:00:00</date-time></dtstart><duration><duration>PT1H</duration></duration><recurrence-id><parameters><tzid><text>US/Eastern</text></tzid></parameters><date-time>2006-01-04T12:00:00</date-time></recurrence-id><summary><text>Event #2 bis</text></summary><uid><text>12345</text></uid></properties></vevent></components></vcalendar></icalendar>',
174
+                'application/calendar+xml',
175
+            ],
176
+        ];
177
+    }
178 178
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/CalendarHomeTest.php 1 patch
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -24,324 +24,324 @@
 block discarded – undo
24 24
 use Test\TestCase;
25 25
 
26 26
 class CalendarHomeTest extends TestCase {
27
-	private CalDavBackend&MockObject $backend;
28
-	private array $principalInfo = [];
29
-	private PluginManager&MockObject $pluginManager;
30
-	private LoggerInterface&MockObject $logger;
31
-	private CalendarHome $calendarHome;
32
-
33
-	protected function setUp(): void {
34
-		parent::setUp();
35
-
36
-		$this->backend = $this->createMock(CalDavBackend::class);
37
-		$this->principalInfo = [
38
-			'uri' => 'user-principal-123',
39
-		];
40
-		$this->pluginManager = $this->createMock(PluginManager::class);
41
-		$this->logger = $this->createMock(LoggerInterface::class);
42
-
43
-		$this->calendarHome = new CalendarHome(
44
-			$this->backend,
45
-			$this->principalInfo,
46
-			$this->logger,
47
-			false
48
-		);
49
-
50
-		// Replace PluginManager with our mock
51
-		$reflection = new \ReflectionClass($this->calendarHome);
52
-		$reflectionProperty = $reflection->getProperty('pluginManager');
53
-		$reflectionProperty->setValue($this->calendarHome, $this->pluginManager);
54
-	}
55
-
56
-	public function testCreateCalendarValidName(): void {
57
-		/** @var MkCol&MockObject $mkCol */
58
-		$mkCol = $this->createMock(MkCol::class);
59
-
60
-		$mkCol->method('getResourceType')
61
-			->willReturn(['{DAV:}collection',
62
-				'{urn:ietf:params:xml:ns:caldav}calendar']);
63
-		$mkCol->method('getRemainingValues')
64
-			->willReturn(['... properties ...']);
65
-
66
-		$this->backend->expects(self::once())
67
-			->method('createCalendar')
68
-			->with('user-principal-123', 'name123', ['... properties ...']);
69
-
70
-		$this->calendarHome->createExtendedCollection('name123', $mkCol);
71
-	}
72
-
73
-	public function testCreateCalendarReservedName(): void {
74
-		$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
75
-		$this->expectExceptionMessage('The resource you tried to create has a reserved name');
76
-
77
-		/** @var MkCol&MockObject $mkCol */
78
-		$mkCol = $this->createMock(MkCol::class);
79
-
80
-		$this->calendarHome->createExtendedCollection('contact_birthdays', $mkCol);
81
-	}
82
-
83
-	public function testCreateCalendarReservedNameAppGenerated(): void {
84
-		$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
85
-		$this->expectExceptionMessage('The resource you tried to create has a reserved name');
86
-
87
-		/** @var MkCol&MockObject $mkCol */
88
-		$mkCol = $this->createMock(MkCol::class);
89
-
90
-		$this->calendarHome->createExtendedCollection('app-generated--example--foo-1', $mkCol);
91
-	}
92
-
93
-	public function testGetChildren():void {
94
-		$this->backend
95
-			->expects(self::once())
96
-			->method('getCalendarsForUser')
97
-			->with('user-principal-123')
98
-			->willReturn([]);
99
-
100
-		$this->backend
101
-			->expects(self::once())
102
-			->method('getSubscriptionsForUser')
103
-			->with('user-principal-123')
104
-			->willReturn([]);
105
-
106
-		$calendarPlugin1 = $this->createMock(ICalendarProvider::class);
107
-		$calendarPlugin1
108
-			->expects(self::once())
109
-			->method('fetchAllForCalendarHome')
110
-			->with('user-principal-123')
111
-			->willReturn(['plugin1calendar1', 'plugin1calendar2']);
112
-
113
-		$calendarPlugin2 = $this->createMock(ICalendarProvider::class);
114
-		$calendarPlugin2
115
-			->expects(self::once())
116
-			->method('fetchAllForCalendarHome')
117
-			->with('user-principal-123')
118
-			->willReturn(['plugin2calendar1', 'plugin2calendar2']);
119
-
120
-		$this->pluginManager
121
-			->expects(self::once())
122
-			->method('getCalendarPlugins')
123
-			->with()
124
-			->willReturn([$calendarPlugin1, $calendarPlugin2]);
125
-
126
-		$actual = $this->calendarHome->getChildren();
127
-
128
-		$this->assertCount(7, $actual);
129
-		$this->assertInstanceOf(Inbox::class, $actual[0]);
130
-		$this->assertInstanceOf(Outbox::class, $actual[1]);
131
-		$this->assertInstanceOf(TrashbinHome::class, $actual[2]);
132
-		$this->assertEquals('plugin1calendar1', $actual[3]);
133
-		$this->assertEquals('plugin1calendar2', $actual[4]);
134
-		$this->assertEquals('plugin2calendar1', $actual[5]);
135
-		$this->assertEquals('plugin2calendar2', $actual[6]);
136
-	}
137
-
138
-	public function testGetChildNonAppGenerated():void {
139
-		$this->backend
140
-			->expects(self::once())
141
-			->method('getCalendarByUri')
142
-			->with('user-principal-123')
143
-			->willReturn([]);
144
-
145
-		$this->backend
146
-			->expects(self::once())
147
-			->method('getCalendarsForUser')
148
-			->with('user-principal-123')
149
-			->willReturn([]);
150
-
151
-		$this->backend
152
-			->expects(self::once())
153
-			->method('getSubscriptionsForUser')
154
-			->with('user-principal-123')
155
-			->willReturn([]);
156
-
157
-		$this->pluginManager
158
-			->expects(self::never())
159
-			->method('getCalendarPlugins');
160
-
161
-		$this->expectException(\Sabre\DAV\Exception\NotFound::class);
162
-		$this->expectExceptionMessage('Node with name \'personal\' could not be found');
163
-
164
-		$this->calendarHome->getChild('personal');
165
-	}
166
-
167
-	public function testGetChildAppGenerated():void {
168
-		$this->backend
169
-			->expects(self::once())
170
-			->method('getCalendarByUri')
171
-			->with('user-principal-123')
172
-			->willReturn([]);
173
-
174
-		$this->backend
175
-			->expects(self::once())
176
-			->method('getCalendarsForUser')
177
-			->with('user-principal-123')
178
-			->willReturn([]);
179
-
180
-		$this->backend
181
-			->expects(self::once())
182
-			->method('getSubscriptionsForUser')
183
-			->with('user-principal-123')
184
-			->willReturn([]);
185
-
186
-		$calendarPlugin1 = $this->createMock(ICalendarProvider::class);
187
-		$calendarPlugin1
188
-			->expects(self::once())
189
-			->method('getAppId')
190
-			->with()
191
-			->willReturn('calendar_plugin_1');
192
-		$calendarPlugin1
193
-			->expects(self::never())
194
-			->method('hasCalendarInCalendarHome');
195
-		$calendarPlugin1
196
-			->expects(self::never())
197
-			->method('getCalendarInCalendarHome');
198
-
199
-		$externalCalendarMock = $this->createMock(ExternalCalendar::class);
200
-
201
-		$calendarPlugin2 = $this->createMock(ICalendarProvider::class);
202
-		$calendarPlugin2
203
-			->expects(self::once())
204
-			->method('getAppId')
205
-			->with()
206
-			->willReturn('calendar_plugin_2');
207
-		$calendarPlugin2
208
-			->expects(self::once())
209
-			->method('hasCalendarInCalendarHome')
210
-			->with('user-principal-123', 'calendar-uri-from-backend')
211
-			->willReturn(true);
212
-		$calendarPlugin2
213
-			->expects(self::once())
214
-			->method('getCalendarInCalendarHome')
215
-			->with('user-principal-123', 'calendar-uri-from-backend')
216
-			->willReturn($externalCalendarMock);
217
-
218
-		$this->pluginManager
219
-			->expects(self::once())
220
-			->method('getCalendarPlugins')
221
-			->with()
222
-			->willReturn([$calendarPlugin1, $calendarPlugin2]);
223
-
224
-		$actual = $this->calendarHome->getChild('app-generated--calendar_plugin_2--calendar-uri-from-backend');
225
-		$this->assertEquals($externalCalendarMock, $actual);
226
-	}
227
-
228
-	public function testGetChildrenSubscriptions(): void {
229
-		$this->backend
230
-			->expects(self::once())
231
-			->method('getCalendarsForUser')
232
-			->with('user-principal-123')
233
-			->willReturn([]);
234
-
235
-		$this->backend
236
-			->expects(self::once())
237
-			->method('getSubscriptionsForUser')
238
-			->with('user-principal-123')
239
-			->willReturn([
240
-				[
241
-					'id' => 'subscription-1',
242
-					'uri' => 'subscription-1',
243
-					'principaluri' => 'user-principal-123',
244
-					'source' => 'https://localhost/subscription-1',
245
-					// A subscription array has actually more properties.
246
-				],
247
-				[
248
-					'id' => 'subscription-2',
249
-					'uri' => 'subscription-2',
250
-					'principaluri' => 'user-principal-123',
251
-					'source' => 'https://localhost/subscription-2',
252
-					// A subscription array has actually more properties.
253
-				]
254
-			]);
255
-
256
-		/*
27
+    private CalDavBackend&MockObject $backend;
28
+    private array $principalInfo = [];
29
+    private PluginManager&MockObject $pluginManager;
30
+    private LoggerInterface&MockObject $logger;
31
+    private CalendarHome $calendarHome;
32
+
33
+    protected function setUp(): void {
34
+        parent::setUp();
35
+
36
+        $this->backend = $this->createMock(CalDavBackend::class);
37
+        $this->principalInfo = [
38
+            'uri' => 'user-principal-123',
39
+        ];
40
+        $this->pluginManager = $this->createMock(PluginManager::class);
41
+        $this->logger = $this->createMock(LoggerInterface::class);
42
+
43
+        $this->calendarHome = new CalendarHome(
44
+            $this->backend,
45
+            $this->principalInfo,
46
+            $this->logger,
47
+            false
48
+        );
49
+
50
+        // Replace PluginManager with our mock
51
+        $reflection = new \ReflectionClass($this->calendarHome);
52
+        $reflectionProperty = $reflection->getProperty('pluginManager');
53
+        $reflectionProperty->setValue($this->calendarHome, $this->pluginManager);
54
+    }
55
+
56
+    public function testCreateCalendarValidName(): void {
57
+        /** @var MkCol&MockObject $mkCol */
58
+        $mkCol = $this->createMock(MkCol::class);
59
+
60
+        $mkCol->method('getResourceType')
61
+            ->willReturn(['{DAV:}collection',
62
+                '{urn:ietf:params:xml:ns:caldav}calendar']);
63
+        $mkCol->method('getRemainingValues')
64
+            ->willReturn(['... properties ...']);
65
+
66
+        $this->backend->expects(self::once())
67
+            ->method('createCalendar')
68
+            ->with('user-principal-123', 'name123', ['... properties ...']);
69
+
70
+        $this->calendarHome->createExtendedCollection('name123', $mkCol);
71
+    }
72
+
73
+    public function testCreateCalendarReservedName(): void {
74
+        $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
75
+        $this->expectExceptionMessage('The resource you tried to create has a reserved name');
76
+
77
+        /** @var MkCol&MockObject $mkCol */
78
+        $mkCol = $this->createMock(MkCol::class);
79
+
80
+        $this->calendarHome->createExtendedCollection('contact_birthdays', $mkCol);
81
+    }
82
+
83
+    public function testCreateCalendarReservedNameAppGenerated(): void {
84
+        $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
85
+        $this->expectExceptionMessage('The resource you tried to create has a reserved name');
86
+
87
+        /** @var MkCol&MockObject $mkCol */
88
+        $mkCol = $this->createMock(MkCol::class);
89
+
90
+        $this->calendarHome->createExtendedCollection('app-generated--example--foo-1', $mkCol);
91
+    }
92
+
93
+    public function testGetChildren():void {
94
+        $this->backend
95
+            ->expects(self::once())
96
+            ->method('getCalendarsForUser')
97
+            ->with('user-principal-123')
98
+            ->willReturn([]);
99
+
100
+        $this->backend
101
+            ->expects(self::once())
102
+            ->method('getSubscriptionsForUser')
103
+            ->with('user-principal-123')
104
+            ->willReturn([]);
105
+
106
+        $calendarPlugin1 = $this->createMock(ICalendarProvider::class);
107
+        $calendarPlugin1
108
+            ->expects(self::once())
109
+            ->method('fetchAllForCalendarHome')
110
+            ->with('user-principal-123')
111
+            ->willReturn(['plugin1calendar1', 'plugin1calendar2']);
112
+
113
+        $calendarPlugin2 = $this->createMock(ICalendarProvider::class);
114
+        $calendarPlugin2
115
+            ->expects(self::once())
116
+            ->method('fetchAllForCalendarHome')
117
+            ->with('user-principal-123')
118
+            ->willReturn(['plugin2calendar1', 'plugin2calendar2']);
119
+
120
+        $this->pluginManager
121
+            ->expects(self::once())
122
+            ->method('getCalendarPlugins')
123
+            ->with()
124
+            ->willReturn([$calendarPlugin1, $calendarPlugin2]);
125
+
126
+        $actual = $this->calendarHome->getChildren();
127
+
128
+        $this->assertCount(7, $actual);
129
+        $this->assertInstanceOf(Inbox::class, $actual[0]);
130
+        $this->assertInstanceOf(Outbox::class, $actual[1]);
131
+        $this->assertInstanceOf(TrashbinHome::class, $actual[2]);
132
+        $this->assertEquals('plugin1calendar1', $actual[3]);
133
+        $this->assertEquals('plugin1calendar2', $actual[4]);
134
+        $this->assertEquals('plugin2calendar1', $actual[5]);
135
+        $this->assertEquals('plugin2calendar2', $actual[6]);
136
+    }
137
+
138
+    public function testGetChildNonAppGenerated():void {
139
+        $this->backend
140
+            ->expects(self::once())
141
+            ->method('getCalendarByUri')
142
+            ->with('user-principal-123')
143
+            ->willReturn([]);
144
+
145
+        $this->backend
146
+            ->expects(self::once())
147
+            ->method('getCalendarsForUser')
148
+            ->with('user-principal-123')
149
+            ->willReturn([]);
150
+
151
+        $this->backend
152
+            ->expects(self::once())
153
+            ->method('getSubscriptionsForUser')
154
+            ->with('user-principal-123')
155
+            ->willReturn([]);
156
+
157
+        $this->pluginManager
158
+            ->expects(self::never())
159
+            ->method('getCalendarPlugins');
160
+
161
+        $this->expectException(\Sabre\DAV\Exception\NotFound::class);
162
+        $this->expectExceptionMessage('Node with name \'personal\' could not be found');
163
+
164
+        $this->calendarHome->getChild('personal');
165
+    }
166
+
167
+    public function testGetChildAppGenerated():void {
168
+        $this->backend
169
+            ->expects(self::once())
170
+            ->method('getCalendarByUri')
171
+            ->with('user-principal-123')
172
+            ->willReturn([]);
173
+
174
+        $this->backend
175
+            ->expects(self::once())
176
+            ->method('getCalendarsForUser')
177
+            ->with('user-principal-123')
178
+            ->willReturn([]);
179
+
180
+        $this->backend
181
+            ->expects(self::once())
182
+            ->method('getSubscriptionsForUser')
183
+            ->with('user-principal-123')
184
+            ->willReturn([]);
185
+
186
+        $calendarPlugin1 = $this->createMock(ICalendarProvider::class);
187
+        $calendarPlugin1
188
+            ->expects(self::once())
189
+            ->method('getAppId')
190
+            ->with()
191
+            ->willReturn('calendar_plugin_1');
192
+        $calendarPlugin1
193
+            ->expects(self::never())
194
+            ->method('hasCalendarInCalendarHome');
195
+        $calendarPlugin1
196
+            ->expects(self::never())
197
+            ->method('getCalendarInCalendarHome');
198
+
199
+        $externalCalendarMock = $this->createMock(ExternalCalendar::class);
200
+
201
+        $calendarPlugin2 = $this->createMock(ICalendarProvider::class);
202
+        $calendarPlugin2
203
+            ->expects(self::once())
204
+            ->method('getAppId')
205
+            ->with()
206
+            ->willReturn('calendar_plugin_2');
207
+        $calendarPlugin2
208
+            ->expects(self::once())
209
+            ->method('hasCalendarInCalendarHome')
210
+            ->with('user-principal-123', 'calendar-uri-from-backend')
211
+            ->willReturn(true);
212
+        $calendarPlugin2
213
+            ->expects(self::once())
214
+            ->method('getCalendarInCalendarHome')
215
+            ->with('user-principal-123', 'calendar-uri-from-backend')
216
+            ->willReturn($externalCalendarMock);
217
+
218
+        $this->pluginManager
219
+            ->expects(self::once())
220
+            ->method('getCalendarPlugins')
221
+            ->with()
222
+            ->willReturn([$calendarPlugin1, $calendarPlugin2]);
223
+
224
+        $actual = $this->calendarHome->getChild('app-generated--calendar_plugin_2--calendar-uri-from-backend');
225
+        $this->assertEquals($externalCalendarMock, $actual);
226
+    }
227
+
228
+    public function testGetChildrenSubscriptions(): void {
229
+        $this->backend
230
+            ->expects(self::once())
231
+            ->method('getCalendarsForUser')
232
+            ->with('user-principal-123')
233
+            ->willReturn([]);
234
+
235
+        $this->backend
236
+            ->expects(self::once())
237
+            ->method('getSubscriptionsForUser')
238
+            ->with('user-principal-123')
239
+            ->willReturn([
240
+                [
241
+                    'id' => 'subscription-1',
242
+                    'uri' => 'subscription-1',
243
+                    'principaluri' => 'user-principal-123',
244
+                    'source' => 'https://localhost/subscription-1',
245
+                    // A subscription array has actually more properties.
246
+                ],
247
+                [
248
+                    'id' => 'subscription-2',
249
+                    'uri' => 'subscription-2',
250
+                    'principaluri' => 'user-principal-123',
251
+                    'source' => 'https://localhost/subscription-2',
252
+                    // A subscription array has actually more properties.
253
+                ]
254
+            ]);
255
+
256
+        /*
257 257
 		 * @FIXME: PluginManager should be injected via constructor.
258 258
 		 */
259 259
 
260
-		$pluginManager = $this->createMock(PluginManager::class);
261
-		$pluginManager
262
-			->expects(self::once())
263
-			->method('getCalendarPlugins')
264
-			->with()
265
-			->willReturn([]);
266
-
267
-		$calendarHome = new CalendarHome(
268
-			$this->backend,
269
-			$this->principalInfo,
270
-			$this->logger,
271
-			false
272
-		);
273
-
274
-		$reflection = new \ReflectionClass($calendarHome);
275
-		$reflectionProperty = $reflection->getProperty('pluginManager');
276
-		$reflectionProperty->setValue($calendarHome, $pluginManager);
277
-
278
-		$actual = $calendarHome->getChildren();
279
-
280
-		$this->assertCount(5, $actual);
281
-		$this->assertInstanceOf(Inbox::class, $actual[0]);
282
-		$this->assertInstanceOf(Outbox::class, $actual[1]);
283
-		$this->assertInstanceOf(TrashbinHome::class, $actual[2]);
284
-		$this->assertInstanceOf(Subscription::class, $actual[3]);
285
-		$this->assertInstanceOf(Subscription::class, $actual[4]);
286
-	}
287
-
288
-	public function testGetChildrenCachedSubscriptions(): void {
289
-		$this->backend
290
-			->expects(self::once())
291
-			->method('getCalendarsForUser')
292
-			->with('user-principal-123')
293
-			->willReturn([]);
294
-
295
-		$this->backend
296
-			->expects(self::once())
297
-			->method('getSubscriptionsForUser')
298
-			->with('user-principal-123')
299
-			->willReturn([
300
-				[
301
-					'id' => 'subscription-1',
302
-					'uri' => 'subscription-1',
303
-					'principaluris' => 'user-principal-123',
304
-					'source' => 'https://localhost/subscription-1',
305
-					// A subscription array has actually more properties.
306
-				],
307
-				[
308
-					'id' => 'subscription-2',
309
-					'uri' => 'subscription-2',
310
-					'principaluri' => 'user-principal-123',
311
-					'source' => 'https://localhost/subscription-2',
312
-					// A subscription array has actually more properties.
313
-				]
314
-			]);
315
-
316
-		/*
260
+        $pluginManager = $this->createMock(PluginManager::class);
261
+        $pluginManager
262
+            ->expects(self::once())
263
+            ->method('getCalendarPlugins')
264
+            ->with()
265
+            ->willReturn([]);
266
+
267
+        $calendarHome = new CalendarHome(
268
+            $this->backend,
269
+            $this->principalInfo,
270
+            $this->logger,
271
+            false
272
+        );
273
+
274
+        $reflection = new \ReflectionClass($calendarHome);
275
+        $reflectionProperty = $reflection->getProperty('pluginManager');
276
+        $reflectionProperty->setValue($calendarHome, $pluginManager);
277
+
278
+        $actual = $calendarHome->getChildren();
279
+
280
+        $this->assertCount(5, $actual);
281
+        $this->assertInstanceOf(Inbox::class, $actual[0]);
282
+        $this->assertInstanceOf(Outbox::class, $actual[1]);
283
+        $this->assertInstanceOf(TrashbinHome::class, $actual[2]);
284
+        $this->assertInstanceOf(Subscription::class, $actual[3]);
285
+        $this->assertInstanceOf(Subscription::class, $actual[4]);
286
+    }
287
+
288
+    public function testGetChildrenCachedSubscriptions(): void {
289
+        $this->backend
290
+            ->expects(self::once())
291
+            ->method('getCalendarsForUser')
292
+            ->with('user-principal-123')
293
+            ->willReturn([]);
294
+
295
+        $this->backend
296
+            ->expects(self::once())
297
+            ->method('getSubscriptionsForUser')
298
+            ->with('user-principal-123')
299
+            ->willReturn([
300
+                [
301
+                    'id' => 'subscription-1',
302
+                    'uri' => 'subscription-1',
303
+                    'principaluris' => 'user-principal-123',
304
+                    'source' => 'https://localhost/subscription-1',
305
+                    // A subscription array has actually more properties.
306
+                ],
307
+                [
308
+                    'id' => 'subscription-2',
309
+                    'uri' => 'subscription-2',
310
+                    'principaluri' => 'user-principal-123',
311
+                    'source' => 'https://localhost/subscription-2',
312
+                    // A subscription array has actually more properties.
313
+                ]
314
+            ]);
315
+
316
+        /*
317 317
 		 * @FIXME: PluginManager should be injected via constructor.
318 318
 		 */
319 319
 
320
-		$pluginManager = $this->createMock(PluginManager::class);
321
-		$pluginManager
322
-			->expects(self::once())
323
-			->method('getCalendarPlugins')
324
-			->with()
325
-			->willReturn([]);
326
-
327
-		$calendarHome = new CalendarHome(
328
-			$this->backend,
329
-			$this->principalInfo,
330
-			$this->logger,
331
-			true
332
-		);
333
-
334
-		$reflection = new \ReflectionClass($calendarHome);
335
-		$reflectionProperty = $reflection->getProperty('pluginManager');
336
-		$reflectionProperty->setValue($calendarHome, $pluginManager);
337
-
338
-		$actual = $calendarHome->getChildren();
339
-
340
-		$this->assertCount(5, $actual);
341
-		$this->assertInstanceOf(Inbox::class, $actual[0]);
342
-		$this->assertInstanceOf(Outbox::class, $actual[1]);
343
-		$this->assertInstanceOf(TrashbinHome::class, $actual[2]);
344
-		$this->assertInstanceOf(CachedSubscription::class, $actual[3]);
345
-		$this->assertInstanceOf(CachedSubscription::class, $actual[4]);
346
-	}
320
+        $pluginManager = $this->createMock(PluginManager::class);
321
+        $pluginManager
322
+            ->expects(self::once())
323
+            ->method('getCalendarPlugins')
324
+            ->with()
325
+            ->willReturn([]);
326
+
327
+        $calendarHome = new CalendarHome(
328
+            $this->backend,
329
+            $this->principalInfo,
330
+            $this->logger,
331
+            true
332
+        );
333
+
334
+        $reflection = new \ReflectionClass($calendarHome);
335
+        $reflectionProperty = $reflection->getProperty('pluginManager');
336
+        $reflectionProperty->setValue($calendarHome, $pluginManager);
337
+
338
+        $actual = $calendarHome->getChildren();
339
+
340
+        $this->assertCount(5, $actual);
341
+        $this->assertInstanceOf(Inbox::class, $actual[0]);
342
+        $this->assertInstanceOf(Outbox::class, $actual[1]);
343
+        $this->assertInstanceOf(TrashbinHome::class, $actual[2]);
344
+        $this->assertInstanceOf(CachedSubscription::class, $actual[3]);
345
+        $this->assertInstanceOf(CachedSubscription::class, $actual[4]);
346
+    }
347 347
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/OutboxTest.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -13,93 +13,93 @@
 block discarded – undo
13 13
 use Test\TestCase;
14 14
 
15 15
 class OutboxTest extends TestCase {
16
-	private IConfig&MockObject $config;
17
-	private Outbox $outbox;
16
+    private IConfig&MockObject $config;
17
+    private Outbox $outbox;
18 18
 
19
-	protected function setUp(): void {
20
-		parent::setUp();
19
+    protected function setUp(): void {
20
+        parent::setUp();
21 21
 
22
-		$this->config = $this->createMock(IConfig::class);
23
-		$this->outbox = new Outbox($this->config, 'user-principal-123');
24
-	}
22
+        $this->config = $this->createMock(IConfig::class);
23
+        $this->outbox = new Outbox($this->config, 'user-principal-123');
24
+    }
25 25
 
26
-	public function testGetACLFreeBusyEnabled(): void {
27
-		$this->config->expects($this->once())
28
-			->method('getAppValue')
29
-			->with('dav', 'disableFreeBusy', 'no')
30
-			->willReturn('no');
26
+    public function testGetACLFreeBusyEnabled(): void {
27
+        $this->config->expects($this->once())
28
+            ->method('getAppValue')
29
+            ->with('dav', 'disableFreeBusy', 'no')
30
+            ->willReturn('no');
31 31
 
32
-		$this->assertEquals([
33
-			[
34
-				'privilege' => '{DAV:}read',
35
-				'principal' => 'user-principal-123',
36
-				'protected' => true,
37
-			],
38
-			[
39
-				'privilege' => '{DAV:}read',
40
-				'principal' => 'user-principal-123/calendar-proxy-read',
41
-				'protected' => true,
42
-			],
43
-			[
44
-				'privilege' => '{DAV:}read',
45
-				'principal' => 'user-principal-123/calendar-proxy-write',
46
-				'protected' => true,
47
-			],
48
-			[
49
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
50
-				'principal' => 'user-principal-123',
51
-				'protected' => true,
52
-			],
53
-			[
54
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
55
-				'principal' => 'user-principal-123/calendar-proxy-write',
56
-				'protected' => true,
57
-			],
58
-		], $this->outbox->getACL());
59
-	}
32
+        $this->assertEquals([
33
+            [
34
+                'privilege' => '{DAV:}read',
35
+                'principal' => 'user-principal-123',
36
+                'protected' => true,
37
+            ],
38
+            [
39
+                'privilege' => '{DAV:}read',
40
+                'principal' => 'user-principal-123/calendar-proxy-read',
41
+                'protected' => true,
42
+            ],
43
+            [
44
+                'privilege' => '{DAV:}read',
45
+                'principal' => 'user-principal-123/calendar-proxy-write',
46
+                'protected' => true,
47
+            ],
48
+            [
49
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
50
+                'principal' => 'user-principal-123',
51
+                'protected' => true,
52
+            ],
53
+            [
54
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
55
+                'principal' => 'user-principal-123/calendar-proxy-write',
56
+                'protected' => true,
57
+            ],
58
+        ], $this->outbox->getACL());
59
+    }
60 60
 
61
-	public function testGetACLFreeBusyDisabled(): void {
62
-		$this->config->expects($this->once())
63
-			->method('getAppValue')
64
-			->with('dav', 'disableFreeBusy', 'no')
65
-			->willReturn('yes');
61
+    public function testGetACLFreeBusyDisabled(): void {
62
+        $this->config->expects($this->once())
63
+            ->method('getAppValue')
64
+            ->with('dav', 'disableFreeBusy', 'no')
65
+            ->willReturn('yes');
66 66
 
67
-		$this->assertEquals([
68
-			[
69
-				'privilege' => '{DAV:}read',
70
-				'principal' => 'user-principal-123',
71
-				'protected' => true,
72
-			],
73
-			[
74
-				'privilege' => '{DAV:}read',
75
-				'principal' => 'user-principal-123/calendar-proxy-read',
76
-				'protected' => true,
77
-			],
78
-			[
79
-				'privilege' => '{DAV:}read',
80
-				'principal' => 'user-principal-123/calendar-proxy-write',
81
-				'protected' => true,
82
-			],
83
-			[
84
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
85
-				'principal' => 'user-principal-123',
86
-				'protected' => true,
87
-			],
88
-			[
89
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
90
-				'principal' => 'user-principal-123/calendar-proxy-write',
91
-				'protected' => true,
92
-			],
93
-			[
94
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
95
-				'principal' => 'user-principal-123',
96
-				'protected' => true,
97
-			],
98
-			[
99
-				'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
100
-				'principal' => 'user-principal-123/calendar-proxy-write',
101
-				'protected' => true,
102
-			],
103
-		], $this->outbox->getACL());
104
-	}
67
+        $this->assertEquals([
68
+            [
69
+                'privilege' => '{DAV:}read',
70
+                'principal' => 'user-principal-123',
71
+                'protected' => true,
72
+            ],
73
+            [
74
+                'privilege' => '{DAV:}read',
75
+                'principal' => 'user-principal-123/calendar-proxy-read',
76
+                'protected' => true,
77
+            ],
78
+            [
79
+                'privilege' => '{DAV:}read',
80
+                'principal' => 'user-principal-123/calendar-proxy-write',
81
+                'protected' => true,
82
+            ],
83
+            [
84
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
85
+                'principal' => 'user-principal-123',
86
+                'protected' => true,
87
+            ],
88
+            [
89
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
90
+                'principal' => 'user-principal-123/calendar-proxy-write',
91
+                'protected' => true,
92
+            ],
93
+            [
94
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
95
+                'principal' => 'user-principal-123',
96
+                'protected' => true,
97
+            ],
98
+            [
99
+                'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
100
+                'principal' => 'user-principal-123/calendar-proxy-write',
101
+                'protected' => true,
102
+            ],
103
+        ], $this->outbox->getACL());
104
+    }
105 105
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@
 block discarded – undo
10 10
 use OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend;
11 11
 
12 12
 class RoomPrincipalBackendTest extends AbstractPrincipalBackendTestCase {
13
-	protected function setUp(): void {
14
-		parent::setUp();
13
+    protected function setUp(): void {
14
+        parent::setUp();
15 15
 
16
-		$this->principalBackend = new RoomPrincipalBackend(self::$realDatabase,
17
-			$this->userSession, $this->groupManager, $this->logger, $this->proxyMapper);
16
+        $this->principalBackend = new RoomPrincipalBackend(self::$realDatabase,
17
+            $this->userSession, $this->groupManager, $this->logger, $this->proxyMapper);
18 18
 
19
-		$this->mainDbTable = 'calendar_rooms';
20
-		$this->metadataDbTable = 'calendar_rooms_md';
21
-		$this->foreignKey = 'room_id';
19
+        $this->mainDbTable = 'calendar_rooms';
20
+        $this->metadataDbTable = 'calendar_rooms_md';
21
+        $this->foreignKey = 'room_id';
22 22
 
23
-		$this->principalPrefix = 'principals/calendar-rooms';
24
-		$this->expectedCUType = 'ROOM';
23
+        $this->principalPrefix = 'principals/calendar-rooms';
24
+        $this->expectedCUType = 'ROOM';
25 25
 
26
-		$this->createTestDatasetInDb();
27
-	}
26
+        $this->createTestDatasetInDb();
27
+    }
28 28
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@
 block discarded – undo
10 10
 use OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend;
11 11
 
12 12
 class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTestCase {
13
-	protected function setUp(): void {
14
-		parent::setUp();
13
+    protected function setUp(): void {
14
+        parent::setUp();
15 15
 
16
-		$this->principalBackend = new ResourcePrincipalBackend(self::$realDatabase,
17
-			$this->userSession, $this->groupManager, $this->logger, $this->proxyMapper);
16
+        $this->principalBackend = new ResourcePrincipalBackend(self::$realDatabase,
17
+            $this->userSession, $this->groupManager, $this->logger, $this->proxyMapper);
18 18
 
19
-		$this->mainDbTable = 'calendar_resources';
20
-		$this->metadataDbTable = 'calendar_resources_md';
21
-		$this->foreignKey = 'resource_id';
19
+        $this->mainDbTable = 'calendar_resources';
20
+        $this->metadataDbTable = 'calendar_resources_md';
21
+        $this->foreignKey = 'resource_id';
22 22
 
23
-		$this->principalPrefix = 'principals/calendar-resources';
24
-		$this->expectedCUType = 'RESOURCE';
23
+        $this->principalPrefix = 'principals/calendar-resources';
24
+        $this->expectedCUType = 'RESOURCE';
25 25
 
26
-		$this->createTestDatasetInDb();
27
-	}
26
+        $this->createTestDatasetInDb();
27
+    }
28 28
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/Listener/CalendarShareUpdateListenerTest.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@
 block discarded – undo
16 16
 use Test\TestCase;
17 17
 
18 18
 class CalendarShareUpdateListenerTest extends TestCase {
19
-	private Backend&MockObject $activityBackend;
20
-	private LoggerInterface&MockObject $logger;
21
-	private CalendarShareUpdateListener $calendarPublicationListener;
22
-	private CalendarShareUpdatedEvent&MockObject $event;
19
+    private Backend&MockObject $activityBackend;
20
+    private LoggerInterface&MockObject $logger;
21
+    private CalendarShareUpdateListener $calendarPublicationListener;
22
+    private CalendarShareUpdatedEvent&MockObject $event;
23 23
 
24
-	protected function setUp(): void {
25
-		parent::setUp();
24
+    protected function setUp(): void {
25
+        parent::setUp();
26 26
 
27
-		$this->activityBackend = $this->createMock(Backend::class);
28
-		$this->logger = $this->createMock(LoggerInterface::class);
29
-		$this->event = $this->createMock(CalendarShareUpdatedEvent::class);
30
-		$this->calendarPublicationListener = new CalendarShareUpdateListener($this->activityBackend, $this->logger);
31
-	}
27
+        $this->activityBackend = $this->createMock(Backend::class);
28
+        $this->logger = $this->createMock(LoggerInterface::class);
29
+        $this->event = $this->createMock(CalendarShareUpdatedEvent::class);
30
+        $this->calendarPublicationListener = new CalendarShareUpdateListener($this->activityBackend, $this->logger);
31
+    }
32 32
 
33
-	public function testInvalidEvent(): void {
34
-		$this->activityBackend->expects($this->never())->method('onCalendarUpdateShares');
35
-		$this->logger->expects($this->never())->method('debug');
36
-		$this->calendarPublicationListener->handle(new Event());
37
-	}
33
+    public function testInvalidEvent(): void {
34
+        $this->activityBackend->expects($this->never())->method('onCalendarUpdateShares');
35
+        $this->logger->expects($this->never())->method('debug');
36
+        $this->calendarPublicationListener->handle(new Event());
37
+    }
38 38
 
39
-	public function testEvent(): void {
40
-		$this->event->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
41
-		$this->event->expects($this->once())->method('getOldShares')->with()->willReturn([]);
42
-		$this->event->expects($this->once())->method('getAdded')->with()->willReturn([]);
43
-		$this->event->expects($this->once())->method('getRemoved')->with()->willReturn([]);
44
-		$this->activityBackend->expects($this->once())->method('onCalendarUpdateShares')->with([], [], [], []);
45
-		$this->logger->expects($this->once())->method('debug');
46
-		$this->calendarPublicationListener->handle($this->event);
47
-	}
39
+    public function testEvent(): void {
40
+        $this->event->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
41
+        $this->event->expects($this->once())->method('getOldShares')->with()->willReturn([]);
42
+        $this->event->expects($this->once())->method('getAdded')->with()->willReturn([]);
43
+        $this->event->expects($this->once())->method('getRemoved')->with()->willReturn([]);
44
+        $this->activityBackend->expects($this->once())->method('onCalendarUpdateShares')->with([], [], [], []);
45
+        $this->logger->expects($this->once())->method('debug');
46
+        $this->calendarPublicationListener->handle($this->event);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/Listener/CalendarPublicationListenerTest.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,39 +17,39 @@
 block discarded – undo
17 17
 use Test\TestCase;
18 18
 
19 19
 class CalendarPublicationListenerTest extends TestCase {
20
-	private Backend&MockObject $activityBackend;
21
-	private LoggerInterface&MockObject $logger;
22
-	private CalendarPublicationListener $calendarPublicationListener;
23
-	private CalendarPublishedEvent&MockObject $publicationEvent;
24
-	private CalendarUnpublishedEvent&MockObject $unpublicationEvent;
25
-
26
-	protected function setUp(): void {
27
-		parent::setUp();
28
-
29
-		$this->activityBackend = $this->createMock(Backend::class);
30
-		$this->logger = $this->createMock(LoggerInterface::class);
31
-		$this->publicationEvent = $this->createMock(CalendarPublishedEvent::class);
32
-		$this->unpublicationEvent = $this->createMock(CalendarUnpublishedEvent::class);
33
-		$this->calendarPublicationListener = new CalendarPublicationListener($this->activityBackend, $this->logger);
34
-	}
35
-
36
-	public function testInvalidEvent(): void {
37
-		$this->activityBackend->expects($this->never())->method('onCalendarPublication');
38
-		$this->logger->expects($this->never())->method('debug');
39
-		$this->calendarPublicationListener->handle(new Event());
40
-	}
41
-
42
-	public function testPublicationEvent(): void {
43
-		$this->publicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
44
-		$this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], true);
45
-		$this->logger->expects($this->once())->method('debug');
46
-		$this->calendarPublicationListener->handle($this->publicationEvent);
47
-	}
48
-
49
-	public function testUnPublicationEvent(): void {
50
-		$this->unpublicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
51
-		$this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], false);
52
-		$this->logger->expects($this->once())->method('debug');
53
-		$this->calendarPublicationListener->handle($this->unpublicationEvent);
54
-	}
20
+    private Backend&MockObject $activityBackend;
21
+    private LoggerInterface&MockObject $logger;
22
+    private CalendarPublicationListener $calendarPublicationListener;
23
+    private CalendarPublishedEvent&MockObject $publicationEvent;
24
+    private CalendarUnpublishedEvent&MockObject $unpublicationEvent;
25
+
26
+    protected function setUp(): void {
27
+        parent::setUp();
28
+
29
+        $this->activityBackend = $this->createMock(Backend::class);
30
+        $this->logger = $this->createMock(LoggerInterface::class);
31
+        $this->publicationEvent = $this->createMock(CalendarPublishedEvent::class);
32
+        $this->unpublicationEvent = $this->createMock(CalendarUnpublishedEvent::class);
33
+        $this->calendarPublicationListener = new CalendarPublicationListener($this->activityBackend, $this->logger);
34
+    }
35
+
36
+    public function testInvalidEvent(): void {
37
+        $this->activityBackend->expects($this->never())->method('onCalendarPublication');
38
+        $this->logger->expects($this->never())->method('debug');
39
+        $this->calendarPublicationListener->handle(new Event());
40
+    }
41
+
42
+    public function testPublicationEvent(): void {
43
+        $this->publicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
44
+        $this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], true);
45
+        $this->logger->expects($this->once())->method('debug');
46
+        $this->calendarPublicationListener->handle($this->publicationEvent);
47
+    }
48
+
49
+    public function testUnPublicationEvent(): void {
50
+        $this->unpublicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]);
51
+        $this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], false);
52
+        $this->logger->expects($this->once())->method('debug');
53
+        $this->calendarPublicationListener->handle($this->unpublicationEvent);
54
+    }
55 55
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/Listener/SubscriptionListenerTest.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,48 +20,48 @@
 block discarded – undo
20 20
 use Test\TestCase;
21 21
 
22 22
 class SubscriptionListenerTest extends TestCase {
23
-	private RefreshWebcalService&MockObject $refreshWebcalService;
24
-	private Backend&MockObject $reminderBackend;
25
-	private IJobList&MockObject $jobList;
26
-	private LoggerInterface&MockObject $logger;
27
-	private SubscriptionListener $calendarPublicationListener;
28
-	private SubscriptionCreatedEvent&MockObject $subscriptionCreatedEvent;
29
-	private SubscriptionDeletedEvent&MockObject $subscriptionDeletedEvent;
23
+    private RefreshWebcalService&MockObject $refreshWebcalService;
24
+    private Backend&MockObject $reminderBackend;
25
+    private IJobList&MockObject $jobList;
26
+    private LoggerInterface&MockObject $logger;
27
+    private SubscriptionListener $calendarPublicationListener;
28
+    private SubscriptionCreatedEvent&MockObject $subscriptionCreatedEvent;
29
+    private SubscriptionDeletedEvent&MockObject $subscriptionDeletedEvent;
30 30
 
31
-	protected function setUp(): void {
32
-		parent::setUp();
31
+    protected function setUp(): void {
32
+        parent::setUp();
33 33
 
34
-		$this->refreshWebcalService = $this->createMock(RefreshWebcalService::class);
35
-		$this->reminderBackend = $this->createMock(Backend::class);
36
-		$this->jobList = $this->createMock(IJobList::class);
37
-		$this->logger = $this->createMock(LoggerInterface::class);
38
-		$this->subscriptionCreatedEvent = $this->createMock(SubscriptionCreatedEvent::class);
39
-		$this->subscriptionDeletedEvent = $this->createMock(SubscriptionDeletedEvent::class);
40
-		$this->calendarPublicationListener = new SubscriptionListener($this->jobList, $this->refreshWebcalService, $this->reminderBackend, $this->logger);
41
-	}
34
+        $this->refreshWebcalService = $this->createMock(RefreshWebcalService::class);
35
+        $this->reminderBackend = $this->createMock(Backend::class);
36
+        $this->jobList = $this->createMock(IJobList::class);
37
+        $this->logger = $this->createMock(LoggerInterface::class);
38
+        $this->subscriptionCreatedEvent = $this->createMock(SubscriptionCreatedEvent::class);
39
+        $this->subscriptionDeletedEvent = $this->createMock(SubscriptionDeletedEvent::class);
40
+        $this->calendarPublicationListener = new SubscriptionListener($this->jobList, $this->refreshWebcalService, $this->reminderBackend, $this->logger);
41
+    }
42 42
 
43
-	public function testInvalidEvent(): void {
44
-		$this->refreshWebcalService->expects($this->never())->method('refreshSubscription');
45
-		$this->jobList->expects($this->never())->method('add');
46
-		$this->logger->expects($this->never())->method('debug');
47
-		$this->calendarPublicationListener->handle(new Event());
48
-	}
43
+    public function testInvalidEvent(): void {
44
+        $this->refreshWebcalService->expects($this->never())->method('refreshSubscription');
45
+        $this->jobList->expects($this->never())->method('add');
46
+        $this->logger->expects($this->never())->method('debug');
47
+        $this->calendarPublicationListener->handle(new Event());
48
+    }
49 49
 
50
-	public function testCreateSubscriptionEvent(): void {
51
-		$this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5);
52
-		$this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']);
53
-		$this->refreshWebcalService->expects($this->once())->method('refreshSubscription')->with('principaluri', 'uri');
54
-		$this->jobList->expects($this->once())->method('add')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']);
55
-		$this->logger->expects($this->exactly(2))->method('debug');
56
-		$this->calendarPublicationListener->handle($this->subscriptionCreatedEvent);
57
-	}
50
+    public function testCreateSubscriptionEvent(): void {
51
+        $this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5);
52
+        $this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']);
53
+        $this->refreshWebcalService->expects($this->once())->method('refreshSubscription')->with('principaluri', 'uri');
54
+        $this->jobList->expects($this->once())->method('add')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']);
55
+        $this->logger->expects($this->exactly(2))->method('debug');
56
+        $this->calendarPublicationListener->handle($this->subscriptionCreatedEvent);
57
+    }
58 58
 
59
-	public function testDeleteSubscriptionEvent(): void {
60
-		$this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5);
61
-		$this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']);
62
-		$this->jobList->expects($this->once())->method('remove')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']);
63
-		$this->reminderBackend->expects($this->once())->method('cleanRemindersForCalendar')->with(5);
64
-		$this->logger->expects($this->exactly(2))->method('debug');
65
-		$this->calendarPublicationListener->handle($this->subscriptionDeletedEvent);
66
-	}
59
+    public function testDeleteSubscriptionEvent(): void {
60
+        $this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5);
61
+        $this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']);
62
+        $this->jobList->expects($this->once())->method('remove')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']);
63
+        $this->reminderBackend->expects($this->once())->method('cleanRemindersForCalendar')->with(5);
64
+        $this->logger->expects($this->exactly(2))->method('debug');
65
+        $this->calendarPublicationListener->handle($this->subscriptionDeletedEvent);
66
+    }
67 67
 }
Please login to merge, or discard this patch.
apps/dav/tests/unit/CalDAV/PluginTest.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 use Test\TestCase;
12 12
 
13 13
 class PluginTest extends TestCase {
14
-	private Plugin $plugin;
15
-
16
-	protected function setUp(): void {
17
-		parent::setUp();
18
-
19
-		$this->plugin = new Plugin();
20
-	}
21
-
22
-	public static function linkProvider(): array {
23
-		return [
24
-			[
25
-				'principals/users/MyUserName',
26
-				'calendars/MyUserName',
27
-			],
28
-			[
29
-				'principals/calendar-resources/Resource-ABC',
30
-				'system-calendars/calendar-resources/Resource-ABC',
31
-			],
32
-			[
33
-				'principals/calendar-rooms/Room-ABC',
34
-				'system-calendars/calendar-rooms/Room-ABC',
35
-			],
36
-		];
37
-	}
38
-
39
-	/**
40
-	 * @dataProvider linkProvider
41
-	 */
42
-	public function testGetCalendarHomeForPrincipal(string $input, string $expected): void {
43
-		$this->assertSame($expected, $this->plugin->getCalendarHomeForPrincipal($input));
44
-	}
45
-
46
-	public function testGetCalendarHomeForUnknownPrincipal(): void {
47
-		$this->assertNull($this->plugin->getCalendarHomeForPrincipal('FOO/BAR/BLUB'));
48
-	}
14
+    private Plugin $plugin;
15
+
16
+    protected function setUp(): void {
17
+        parent::setUp();
18
+
19
+        $this->plugin = new Plugin();
20
+    }
21
+
22
+    public static function linkProvider(): array {
23
+        return [
24
+            [
25
+                'principals/users/MyUserName',
26
+                'calendars/MyUserName',
27
+            ],
28
+            [
29
+                'principals/calendar-resources/Resource-ABC',
30
+                'system-calendars/calendar-resources/Resource-ABC',
31
+            ],
32
+            [
33
+                'principals/calendar-rooms/Room-ABC',
34
+                'system-calendars/calendar-rooms/Room-ABC',
35
+            ],
36
+        ];
37
+    }
38
+
39
+    /**
40
+     * @dataProvider linkProvider
41
+     */
42
+    public function testGetCalendarHomeForPrincipal(string $input, string $expected): void {
43
+        $this->assertSame($expected, $this->plugin->getCalendarHomeForPrincipal($input));
44
+    }
45
+
46
+    public function testGetCalendarHomeForUnknownPrincipal(): void {
47
+        $this->assertNull($this->plugin->getCalendarHomeForPrincipal('FOO/BAR/BLUB'));
48
+    }
49 49
 }
Please login to merge, or discard this patch.