@@ -1840,6 +1840,72 @@ public function testSearchShouldReturnObjectsInTheSameOrderMissingDate(): void {
18401840 $ this ->assertEquals ('Missing DTSTART 2 ' , $ results [3 ]['objects ' ][0 ]['SUMMARY ' ][0 ]);
18411841 }
18421842
1843+ public function testSearchByUri (): void {
1844+ $ calendarId = $ this ->createTestCalendar ();
1845+ $ uris = [];
1846+ $ calData = [];
1847+
1848+ $ uris [] = static ::getUniqueID ('calobj ' );
1849+ $ calData [] = <<<'EOD'
1850+ BEGIN:VCALENDAR
1851+ VERSION:2.0
1852+ PRODID:Nextcloud Calendar
1853+ BEGIN:VEVENT
1854+ CREATED;VALUE=DATE-TIME:20260323T093039Z
1855+ UID:search-by-uri-test1
1856+ LAST-MODIFIED;VALUE=DATE-TIME:20260323T093039Z
1857+ DTSTAMP;VALUE=DATE-TIME:20260323T093039Z
1858+ SUMMARY:First Test Event
1859+ DTSTART;VALUE=DATE-TIME:20260323T093039Z
1860+ DTEND;VALUE=DATE-TIME:20260323T093039Z
1861+ CLASS:PUBLIC
1862+ END:VEVENT
1863+ END:VCALENDAR
1864+ EOD;
1865+
1866+ $ uris [] = static ::getUniqueID ('calobj ' );
1867+ $ calData [] = <<<'EOD'
1868+ BEGIN:VCALENDAR
1869+ VERSION:2.0
1870+ PRODID:Nextcloud Calendar
1871+ BEGIN:VEVENT
1872+ CREATED;VALUE=DATE-TIME:20260323T093039Z
1873+ UID:search-by-uri-test2
1874+ LAST-MODIFIED;VALUE=DATE-TIME:20260323T093039Z
1875+ DTSTAMP;VALUE=DATE-TIME:20260323T093039Z
1876+ SUMMARY:Second Test Event
1877+ DTSTART;VALUE=DATE-TIME:20260323T093039Z
1878+ DTEND;VALUE=DATE-TIME:20260323T093039Z
1879+ CLASS:PUBLIC
1880+ END:VEVENT
1881+ END:VCALENDAR
1882+ EOD;
1883+
1884+ foreach ($ uris as $ uri ) {
1885+ $ this ->backend ->createCalendarObject ($ calendarId , $ uri , $ calData [$ i ]);
1886+ }
1887+
1888+ $ calendarInfo = [
1889+ 'id ' => $ calendarId ,
1890+ 'principaluri ' => 'user1 ' ,
1891+ '{http://owncloud.org/ns}owner-principal ' => 'user1 ' ,
1892+ ];
1893+
1894+ // Searching by first event's URI returns this event
1895+ $ results = $ this ->backend ->search ($ calendarInfo , '' , [], ['uri ' => $ uris [0 ]]);
1896+ $ this ->assertCount (1 , $ results );
1897+ $ this ->assertEquals ($ uris [0 ], $ results [0 ]['uri ' ]);
1898+
1899+ // Searching by second event's URI returns this event
1900+ $ results = $ this ->backend ->search ($ calendarInfo , '' , [], ['uri ' => $ uris [1 ]]);
1901+ $ this ->assertCount (1 , $ results );
1902+ $ this ->assertEquals ($ uris [1 ], $ results [0 ]['uri ' ]);
1903+
1904+ // Searching by a non-existent URI returns nothing
1905+ $ result = $ this ->backend ->search ($ calendarInfo , '' , [], ['uri ' => 'nonexistant.ical ' ]);
1906+ $ this ->assertCount (0 , $ result );
1907+ }
1908+
18431909 public function testUnshare (): void {
18441910 $ principalGroup = 'principal: ' . self ::UNIT_TEST_GROUP ;
18451911 $ principalUser = 'principal: ' . self ::UNIT_TEST_USER ;
0 commit comments