1<?php
2
3namespace Sabre\CalDAV\Notifications;
4
5use Sabre\CalDAV;
6
7class CollectionTest extends \PHPUnit_Framework_TestCase {
8
9    protected $caldavBackend;
10    protected $principalUri;
11    protected $notification;
12
13    function getInstance() {
14
15        $this->principalUri = 'principals/user1';
16
17        $this->notification = new CalDAV\Xml\Notification\SystemStatus(1,'"1"');
18
19        $this->caldavBackend = new CalDAV\Backend\MockSharing(array(),array(), array(
20            'principals/user1' => array(
21                $this->notification
22            )
23        ));
24
25        return new Collection($this->caldavBackend, $this->principalUri);
26
27    }
28
29    function testGetChildren() {
30
31        $col = $this->getInstance();
32        $this->assertEquals('notifications', $col->getName());
33
34        $this->assertEquals(array(
35            new Node($this->caldavBackend, $this->principalUri, $this->notification)
36        ), $col->getChildren());
37
38    }
39
40    function testGetOwner() {
41
42        $col = $this->getInstance();
43        $this->assertEquals('principals/user1', $col->getOwner());
44
45    }
46
47    function testGetGroup() {
48
49        $col = $this->getInstance();
50        $this->assertNull($col->getGroup());
51
52    }
53
54    function testGetACL() {
55
56        $col = $this->getInstance();
57        $expected = array(
58            array(
59                'privilege' => '{DAV:}read',
60                'principal' => $this->principalUri,
61                'protected' => true,
62            ),
63            array(
64                'privilege' => '{DAV:}write',
65                'principal' => $this->principalUri,
66                'protected' => true,
67            ),
68        );
69
70        $this->assertEquals($expected, $col->getACL());
71
72    }
73
74    /**
75     * @expectedException Sabre\DAV\Exception\NotImplemented
76     */
77    function testSetACL() {
78
79        $col = $this->getInstance();
80        $col->setACL(array());
81
82    }
83
84    function testGetSupportedPrivilegeSet() {
85
86        $col = $this->getInstance();
87        $this->assertNull($col->getSupportedPrivilegeSet());
88
89    }
90}
91