Skip to content

Commit 3b08dc5

Browse files
committed
[smarcet]
* bug fixing on multistatus response with one single element on collection
1 parent 47b6697 commit 3b08dc5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Facade/Responses/GenericMultiCalDAVResponse.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ class GenericMultiCalDAVResponse extends AbstractCalDAVResponse
2525

2626
protected function parse()
2727
{
28-
if(isset($this->content['response']) && !isset($this->content['response']['propstat']) && count($this->content['response'] > 0)){
29-
foreach($this->content['response'] as $val){
28+
if(isset($this->content['response'])){
29+
30+
if(isset($this->content['response']['propstat'])) {
31+
// its a collection with one single element
32+
$single_resource = $this->buildSingleResponse();
33+
$single_resource->setContent(['response' => $this->content['response']]);
34+
$single_resource->parse();
35+
$this->responses[] = $single_resource;
36+
return;
37+
}
38+
39+
foreach ($this->content['response'] as $val) {
3040
$single_resource = $this->buildSingleResponse();
3141
$single_resource->setContent(['response' => $val]);
3242
$single_resource->parse();

tests/FacadeTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ function testGetEventByUrl(){
166166
}
167167

168168
function testGetEventsByUrl(){
169-
$event_url = '/8244464267/calendars/openstack-summit-sidney-2017/d7a2387264bfa1a619c37a593e94204a.ics';
170-
$event_url2 = '/8244464267/calendars/openstack-summit-sidney-2017/8b91154e5cc76819a473de1a8652cc24.ics';
171-
169+
$event_url = '/8244464267/calendars/openstack-summit-sidney-2017/0df083912b476631bf677c140ad4740b.ics';
172170

173171
$res = self::$client->getEventsBy('https://p01-caldav.icloud.com:443/8244464267/calendars/openstack-summit-sidney-2017/',
174-
[$event_url, $event_url2]);
172+
[$event_url]);
175173

176174
$this->assertTrue($res->isSuccessFull());
177175
}

0 commit comments

Comments
 (0)