1<?php
2
3namespace Sabre\CalDAV;
4
5use Sabre\DAVACL;
6
7require_once 'Sabre/CalDAV/TestUtil.php';
8
9/**
10 */
11class CalendarHomeSharedCalendarsTest extends \PHPUnit_Framework_TestCase {
12
13    protected $backend;
14
15    function getInstance() {
16
17        $calendars = array(
18            array(
19                'id' => 1,
20                'principaluri' => 'principals/user1',
21            ),
22            array(
23                'id' => 2,
24                '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/cal1',
25                '{http://sabredav.org/ns}owner-principal' => 'principal/owner',
26                '{http://sabredav.org/ns}read-only' => false,
27                'principaluri' => 'principals/user1',
28            ),
29        );
30
31        $this->backend = new Backend\MockSharing(
32            $calendars,
33            array(),
34            array()
35        );
36
37        return new CalendarHome($this->backend, array(
38            'uri' => 'principals/user1'
39        ));
40
41    }
42
43    function testSimple() {
44
45        $instance = $this->getInstance();
46        $this->assertEquals('user1', $instance->getName());
47
48    }
49
50    function testGetChildren() {
51
52        $instance = $this->getInstance();
53        $children = $instance->getChildren();
54        $this->assertEquals(3, count($children));
55
56        // Testing if we got all the objects back.
57        $hasShareable = false;
58        $hasShared = false;
59        $hasOutbox = false;
60        $hasNotifications = false;
61
62        foreach($children as $child) {
63
64            if ($child instanceof IShareableCalendar) {
65                $hasShareable = true;
66            }
67            if ($child instanceof ISharedCalendar) {
68                $hasShared = true;
69            }
70            if ($child instanceof Notifications\ICollection) {
71                $hasNotifications = true;
72            }
73
74        }
75        if (!$hasShareable) $this->fail('Missing node!');
76        if (!$hasShared) $this->fail('Missing node!');
77        if (!$hasNotifications) $this->fail('Missing node!');
78
79    }
80
81    function testShareReply() {
82
83        $instance = $this->getInstance();
84        $result = $instance->shareReply('uri', SharingPlugin::STATUS_DECLINED, 'curi', '1');
85        $this->assertNull($result);
86
87    }
88
89}
90