aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php
blob: 04fb16df5304f7aad5145f9fc6c46e8ebc58d177 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php

namespace Sabre\CalDAV\Backend;

class AbstractTest extends \PHPUnit_Framework_TestCase {

    function testUpdateCalendar() {

        $abstract = new AbstractMock();
        $this->assertEquals(false, $abstract->updateCalendar('randomid', array('{DAV:}displayname' => 'anything')));

    }

    function testCalendarQuery() {

        $abstract = new AbstractMock();
        $filters = array(
            'name' => 'VCALENDAR',
            'comp-filters' => array(
                array(
                    'name' => 'VEVENT',
                    'comp-filters' => array(),
                    'prop-filters' => array(),
                    'is-not-defined' => false,
                    'time-range' => null,
                ),
            ),
            'prop-filters' => array(),
            'is-not-defined' => false,
            'time-range' => null,
        );

        $this->assertEquals(array(
            'event1.ics',
        ), $abstract->calendarQuery(1, $filters));

    }

}

class AbstractMock extends AbstractBackend {

    function getCalendarsForUser($principalUri) { }
    function createCalendar($principalUri,$calendarUri,array $properties) { }
    function deleteCalendar($calendarId) { }
    function getCalendarObjects($calendarId) { 

        return array(
            array(
                'id' => 1,
                'calendarid' => 1,
                'uri' => 'event1.ics',
            ),
            array(
                'id' => 2,
                'calendarid' => 1,
                'uri' => 'task1.ics',
            ),
        );

    }
    function getCalendarObject($calendarId,$objectUri) { 

        switch($objectUri) {

            case 'event1.ics' :
                return array(
                    'id' => 1,
                    'calendarid' => 1,
                    'uri' => 'event1.ics',
                    'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
                );
            case 'task1.ics' :
                return array(
                    'id' => 1,
                    'calendarid' => 1,
                    'uri' => 'event1.ics',
                    'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n",
                );

        }

    }
    function createCalendarObject($calendarId,$objectUri,$calendarData) { }
    function updateCalendarObject($calendarId,$objectUri,$calendarData) { }
    function deleteCalendarObject($calendarId,$objectUri) { }

}