use Sabre\VObject\ParseException;
use Sabre\VObject\Reader;
use Sabre\VObject\Splitter\ICalendar;
+use Sabre\VObject\UUIDUtil;
use function count;
class RefreshWebcalService {
while ($vObject = $splitter->getNext()) {
/** @var Component $vObject */
- $uid = null;
$compName = null;
foreach ($vObject->getComponents() as $component) {
continue;
}
- $uid = $component->{'UID'}->getValue();
$compName = $component->name;
if ($stripAlarms) {
continue;
}
- $uri = $uid . '.ics';
+ $uri = $this->getRandomCalendarObjectUri();
$calendarData = $vObject->serialize();
try {
$this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
return $cleanURL;
}
+
+ /**
+ * Returns a random uri for a calendar-object
+ *
+ * @return string
+ */
+ public function getRandomCalendarObjectUri():string {
+ return UUIDUtil::getUUID() . '.ics';
+ }
}
* @dataProvider runDataProvider
*/
public function testRun(string $body, string $contentType, string $result) {
- $refreshWebcalService = new RefreshWebcalService($this->caldavBackend,
- $this->clientService, $this->config, $this->logger);
+ $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
+ ->setMethods(['getRandomCalendarObjectUri'])
+ ->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
+ ->getMock();
+
+ $refreshWebcalService
+ ->method('getRandomCalendarObjectUri')
+ ->willReturn('uri-1.ics');
$this->caldavBackend->expects($this->once())
->method('getSubscriptionsForUser')
$this->caldavBackend->expects($this->once())
->method('createCalendarObject')
- ->with(42, '12345.ics', $result, 1);
+ ->with(42, 'uri-1.ics', $result, 1);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}