aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
blob: 4c3bae3a4bfee0fba8df33eb29013bb18014525c (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
89
90
91
92
93
<?php

namespace Sabre\CalDAV;

use Sabre\DAVACL;

require_once 'Sabre/CalDAV/TestUtil.php';

/**
 * @covers Sabre\CalDAV\UserCalendars
 */
class UserCalendarsSharedCalendarsTest extends \PHPUnit_Framework_TestCase {

    protected $backend;

    function getInstance() {

        $calendars = array(
            array(
                'id' => 1,
                'principaluri' => 'principals/user1',
            ),
            array(
                'id' => 2,
                '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/cal1',
                '{http://sabredav.org/ns}owner-principal' => 'principal/owner',
                '{http://sabredav.org/ns}read-only' => false,
                'principaluri' => 'principals/user1',
            ),
        );

        $this->backend = new Backend\Mock(
            $calendars,
            array(),
            array()
        );

        return new UserCalendars($this->backend, array(
            'uri' => 'principals/user1'
        ));

    }

    function testSimple() {

        $instance = $this->getInstance();
        $this->assertEquals('user1', $instance->getName());

    }

    function testGetChildren() {

        $instance = $this->getInstance();
        $children = $instance->getChildren();
        $this->assertEquals(4, count($children));

        // Testing if we got all the objects back.
        $hasShareable = false;
        $hasShared = false;
        $hasOutbox = false;
        $hasNotifications = false;
        
        foreach($children as $child) {

            if ($child instanceof IShareableCalendar) {
                $hasShareable = true;
            }
            if ($child instanceof ISharedCalendar) {
                $hasShared = true;
            }
            if ($child instanceof Schedule\IOutbox) {
                $hasOutbox = true;
            }
            if ($child instanceof Notifications\ICollection) {
                $hasNotifications = true;
            }

        }
        if (!$hasShareable) $this->fail('Missing node!');
        if (!$hasShared) $this->fail('Missing node!');
        if (!$hasOutbox) $this->fail('Missing node!');
        if (!$hasNotifications) $this->fail('Missing node!'); 

    }
    
    function testShareReply() {

        $instance = $this->getInstance();
        $instance->shareReply('uri', SharingPlugin::STATUS_DECLINED, 'curi', '1');

    }

}