@@ -292,6 +292,46 @@ public function testMultipleCalendarObjectsWithSameUID(): void {
292292 $ this ->backend ->createCalendarObject ($ calendarId , $ uri1 , $ calData );
293293 }
294294
295+ public function testCreateCalendarObjectWithSameUidAsObjectInTrashbin (): void {
296+ $ calendarId = $ this ->createTestCalendar ();
297+
298+ $ calData = <<<'EOD'
299+ BEGIN:VCALENDAR
300+ VERSION:2.0
301+ PRODID:ownCloud Calendar
302+ BEGIN:VEVENT
303+ CREATED;VALUE=DATE-TIME:20130910T125139Z
304+ UID:47d15e3ec8
305+ LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
306+ DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
307+ SUMMARY:Test Event
308+ DTSTART;VALUE=DATE-TIME:20130912T130000Z
309+ DTEND;VALUE=DATE-TIME:20130912T140000Z
310+ CLASS:PUBLIC
311+ END:VEVENT
312+ END:VCALENDAR
313+ EOD;
314+
315+ $ uri = static ::getUniqueID ('event ' ) . '.ics ' ;
316+ $ this ->backend ->createCalendarObject ($ calendarId , $ uri , $ calData );
317+
318+ // Soft-delete the object so it is moved to the trashbin but keeps its UID
319+ $ this ->backend ->deleteCalendarObject ($ calendarId , $ uri );
320+ $ trashbinUri = str_replace ('.ics ' , '-deleted.ics ' , $ uri );
321+ $ trashedObject = $ this ->backend ->getCalendarObject ($ calendarId , $ trashbinUri );
322+ $ this ->assertNotNull ($ trashedObject );
323+
324+ // Recreating an object with the same UID must purge the trashbin entry
325+ // instead of violating the unique index on (calendarid, calendartype, uid)
326+ $ newUri = static ::getUniqueID ('event ' ) . '.ics ' ;
327+ $ this ->backend ->createCalendarObject ($ calendarId , $ newUri , $ calData );
328+
329+ $ this ->assertNull ($ this ->backend ->getCalendarObject ($ calendarId , $ trashbinUri ));
330+ $ newObject = $ this ->backend ->getCalendarObject ($ calendarId , $ newUri );
331+ $ this ->assertNotNull ($ newObject );
332+ $ this ->assertEquals ($ calData , $ newObject ['calendardata ' ]);
333+ }
334+
295335 public function testMultiCalendarObjects (): void {
296336 $ calendarId = $ this ->createTestCalendar ();
297337
0 commit comments