1<?php
2
3namespace Sabre\CalDAV\Principal;
4use Sabre\DAVACL;
5
6class ProxyReadTest extends \PHPUnit_Framework_TestCase {
7
8    protected $backend;
9
10    function getInstance() {
11
12        $backend = new DAVACL\PrincipalBackend\Mock();
13        $principal = new ProxyRead($backend, array(
14            'uri' => 'principal/user',
15        ));
16        $this->backend = $backend;
17        return $principal;
18
19   }
20
21    function testGetName() {
22
23        $i = $this->getInstance();
24        $this->assertEquals('calendar-proxy-read', $i->getName());
25
26    }
27    function testGetDisplayName() {
28
29        $i = $this->getInstance();
30        $this->assertEquals('calendar-proxy-read', $i->getDisplayName());
31
32    }
33
34    function testGetLastModified() {
35
36        $i = $this->getInstance();
37        $this->assertNull($i->getLastModified());
38
39    }
40
41    /**
42     * @expectedException Sabre\DAV\Exception\Forbidden
43     */
44    function testDelete() {
45
46        $i = $this->getInstance();
47        $i->delete();
48
49    }
50
51    /**
52     * @expectedException Sabre\DAV\Exception\Forbidden
53     */
54    function testSetName() {
55
56        $i = $this->getInstance();
57        $i->setName('foo');
58
59    }
60
61    function testGetAlternateUriSet() {
62
63        $i = $this->getInstance();
64        $this->assertEquals(array(), $i->getAlternateUriSet());
65
66    }
67
68    function testGetPrincipalUri() {
69
70        $i = $this->getInstance();
71        $this->assertEquals('principal/user/calendar-proxy-read', $i->getPrincipalUrl());
72
73    }
74
75    function testGetGroupMemberSet() {
76
77        $i = $this->getInstance();
78        $this->assertEquals(array(), $i->getGroupMemberSet());
79
80    }
81
82    function testGetGroupMembership() {
83
84        $i = $this->getInstance();
85        $this->assertEquals(array(), $i->getGroupMembership());
86
87    }
88
89    function testSetGroupMemberSet() {
90
91        $i = $this->getInstance();
92        $i->setGroupMemberSet(array('principals/foo'));
93
94        $expected = array(
95            $i->getPrincipalUrl() => array('principals/foo')
96        );
97
98        $this->assertEquals($expected, $this->backend->groupMembers);
99
100    }
101}
102