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