Skip to content

Commit e8fff40

Browse files
committed
fixup! Remove the loop of calendars when only one is needed
1 parent 231e3a7 commit e8fff40

1 file changed

Lines changed: 36 additions & 18 deletions

File tree

apps/dav/tests/unit/CalDAV/CalendarHomeTest.php

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testCreateCalendarValidName() {
8888
$mkCol->method('getRemainingValues')
8989
->willReturn(['... properties ...']);
9090

91-
$this->backend->expects($this->once())
91+
$this->backend->expects(self::once())
9292
->method('createCalendar')
9393
->with('user-principal-123', 'name123', ['... properties ...']);
9494

@@ -117,33 +117,39 @@ public function testCreateCalendarReservedNameAppGenerated() {
117117

118118
public function testGetChildren():void {
119119
$this->backend
120-
->expects($this->at(0))
120+
->expects(self::once())
121+
->method('getCalendarByUri')
122+
->with('user-principal-123')
123+
->willReturn([]);
124+
125+
$this->backend
126+
->expects(self::once())
121127
->method('getCalendarsForUser')
122128
->with('user-principal-123')
123129
->willReturn([]);
124130

125131
$this->backend
126-
->expects($this->at(1))
132+
->expects(self::once())
127133
->method('getSubscriptionsForUser')
128134
->with('user-principal-123')
129135
->willReturn([]);
130136

131137
$calendarPlugin1 = $this->createMock(ICalendarProvider::class);
132138
$calendarPlugin1
133-
->expects($this->once())
139+
->expects(self::once())
134140
->method('fetchAllForCalendarHome')
135141
->with('user-principal-123')
136142
->willReturn(['plugin1calendar1', 'plugin1calendar2']);
137143

138144
$calendarPlugin2 = $this->createMock(ICalendarProvider::class);
139145
$calendarPlugin2
140-
->expects($this->once())
146+
->expects(self::once())
141147
->method('fetchAllForCalendarHome')
142148
->with('user-principal-123')
143149
->willReturn(['plugin2calendar1', 'plugin2calendar2']);
144150

145151
$this->pluginManager
146-
->expects($this->once())
152+
->expects(self::once())
147153
->method('getCalendarPlugins')
148154
->with()
149155
->willReturn([$calendarPlugin1, $calendarPlugin2]);
@@ -162,19 +168,25 @@ public function testGetChildren():void {
162168

163169
public function testGetChildNonAppGenerated():void {
164170
$this->backend
165-
->expects($this->at(0))
171+
->expects(self::once())
172+
->method('getCalendarByUri')
173+
->with('user-principal-123')
174+
->willReturn([]);
175+
176+
$this->backend
177+
->expects(self::once())
166178
->method('getCalendarsForUser')
167179
->with('user-principal-123')
168180
->willReturn([]);
169181

170182
$this->backend
171-
->expects($this->at(1))
183+
->expects(self::once())
172184
->method('getSubscriptionsForUser')
173185
->with('user-principal-123')
174186
->willReturn([]);
175187

176188
$this->pluginManager
177-
->expects($this->never())
189+
->expects(self::never())
178190
->method('getCalendarPlugins');
179191

180192
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
@@ -185,51 +197,57 @@ public function testGetChildNonAppGenerated():void {
185197

186198
public function testGetChildAppGenerated():void {
187199
$this->backend
188-
->expects($this->at(0))
200+
->expects(self::once())
201+
->method('getCalendarByUri')
202+
->with('user-principal-123')
203+
->willReturn([]);
204+
205+
$this->backend
206+
->expects(self::once())
189207
->method('getCalendarsForUser')
190208
->with('user-principal-123')
191209
->willReturn([]);
192210

193211
$this->backend
194-
->expects($this->at(1))
212+
->expects(self::once())
195213
->method('getSubscriptionsForUser')
196214
->with('user-principal-123')
197215
->willReturn([]);
198216

199217
$calendarPlugin1 = $this->createMock(ICalendarProvider::class);
200218
$calendarPlugin1
201-
->expects($this->once())
219+
->expects(self::once())
202220
->method('getAppId')
203221
->with()
204222
->willReturn('calendar_plugin_1');
205223
$calendarPlugin1
206-
->expects($this->never())
224+
->expects(self::never())
207225
->method('hasCalendarInCalendarHome');
208226
$calendarPlugin1
209-
->expects($this->never())
227+
->expects(self::never())
210228
->method('getCalendarInCalendarHome');
211229

212230
$externalCalendarMock = $this->createMock(ExternalCalendar::class);
213231

214232
$calendarPlugin2 = $this->createMock(ICalendarProvider::class);
215233
$calendarPlugin2
216-
->expects($this->once())
234+
->expects(self::once())
217235
->method('getAppId')
218236
->with()
219237
->willReturn('calendar_plugin_2');
220238
$calendarPlugin2
221-
->expects($this->once())
239+
->expects(self::once())
222240
->method('hasCalendarInCalendarHome')
223241
->with('user-principal-123', 'calendar-uri-from-backend')
224242
->willReturn(true);
225243
$calendarPlugin2
226-
->expects($this->once())
244+
->expects(self::once())
227245
->method('getCalendarInCalendarHome')
228246
->with('user-principal-123', 'calendar-uri-from-backend')
229247
->willReturn($externalCalendarMock);
230248

231249
$this->pluginManager
232-
->expects($this->once())
250+
->expects(self::once())
233251
->method('getCalendarPlugins')
234252
->with()
235253
->willReturn([$calendarPlugin1, $calendarPlugin2]);

0 commit comments

Comments
 (0)