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