xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab) !
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV\Schedule;
4*a1a3b679SAndreas Boehleruse Sabre\CalDAV;
5*a1a3b679SAndreas Boehleruse Sabre\DAV;
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehlerclass OutboxTest extends \PHPUnit_Framework_TestCase {
8*a1a3b679SAndreas Boehler
9*a1a3b679SAndreas Boehler    function testSetup() {
10*a1a3b679SAndreas Boehler
11*a1a3b679SAndreas Boehler        $outbox = new Outbox('principals/user1');
12*a1a3b679SAndreas Boehler        $this->assertEquals('outbox', $outbox->getName());
13*a1a3b679SAndreas Boehler        $this->assertEquals(array(), $outbox->getChildren());
14*a1a3b679SAndreas Boehler        $this->assertEquals('principals/user1', $outbox->getOwner());
15*a1a3b679SAndreas Boehler        $this->assertEquals(null, $outbox->getGroup());
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler        $this->assertEquals(array(
18*a1a3b679SAndreas Boehler            array(
19*a1a3b679SAndreas Boehler                'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
20*a1a3b679SAndreas Boehler                'principal' => 'principals/user1',
21*a1a3b679SAndreas Boehler                'protected' => true,
22*a1a3b679SAndreas Boehler            ),
23*a1a3b679SAndreas Boehler
24*a1a3b679SAndreas Boehler            array(
25*a1a3b679SAndreas Boehler                'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
26*a1a3b679SAndreas Boehler                'principal' => 'principals/user1',
27*a1a3b679SAndreas Boehler                'protected' => true,
28*a1a3b679SAndreas Boehler            ),
29*a1a3b679SAndreas Boehler            array(
30*a1a3b679SAndreas Boehler                'privilege' => '{DAV:}read',
31*a1a3b679SAndreas Boehler                'principal' => 'principals/user1',
32*a1a3b679SAndreas Boehler                'protected' => true,
33*a1a3b679SAndreas Boehler            ),
34*a1a3b679SAndreas Boehler            array(
35*a1a3b679SAndreas Boehler                'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
36*a1a3b679SAndreas Boehler                'principal' => 'principals/user1/calendar-proxy-write',
37*a1a3b679SAndreas Boehler                'protected' => true,
38*a1a3b679SAndreas Boehler            ),
39*a1a3b679SAndreas Boehler            array(
40*a1a3b679SAndreas Boehler                'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
41*a1a3b679SAndreas Boehler                'principal' => 'principals/user1/calendar-proxy-write',
42*a1a3b679SAndreas Boehler                'protected' => true,
43*a1a3b679SAndreas Boehler            ),
44*a1a3b679SAndreas Boehler            array(
45*a1a3b679SAndreas Boehler                'privilege' => '{DAV:}read',
46*a1a3b679SAndreas Boehler                'principal' => 'principals/user1/calendar-proxy-read',
47*a1a3b679SAndreas Boehler                'protected' => true,
48*a1a3b679SAndreas Boehler            ),
49*a1a3b679SAndreas Boehler            array(
50*a1a3b679SAndreas Boehler                'privilege' => '{DAV:}read',
51*a1a3b679SAndreas Boehler                'principal' => 'principals/user1/calendar-proxy-write',
52*a1a3b679SAndreas Boehler                'protected' => true,
53*a1a3b679SAndreas Boehler            ),
54*a1a3b679SAndreas Boehler        ), $outbox->getACL());
55*a1a3b679SAndreas Boehler
56*a1a3b679SAndreas Boehler        $ok = false;
57*a1a3b679SAndreas Boehler        try {
58*a1a3b679SAndreas Boehler            $outbox->setACL(array());
59*a1a3b679SAndreas Boehler        } catch (DAV\Exception\MethodNotAllowed $e) {
60*a1a3b679SAndreas Boehler            $ok = true;
61*a1a3b679SAndreas Boehler        }
62*a1a3b679SAndreas Boehler        if (!$ok) {
63*a1a3b679SAndreas Boehler            $this->fail('Exception was not emitted');
64*a1a3b679SAndreas Boehler        }
65*a1a3b679SAndreas Boehler
66*a1a3b679SAndreas Boehler    }
67*a1a3b679SAndreas Boehler
68*a1a3b679SAndreas Boehler    function testGetSupportedPrivilegeSet() {
69*a1a3b679SAndreas Boehler
70*a1a3b679SAndreas Boehler        $outbox = new Outbox('principals/user1');
71*a1a3b679SAndreas Boehler        $r = $outbox->getSupportedPrivilegeSet();
72*a1a3b679SAndreas Boehler
73*a1a3b679SAndreas Boehler        $ok = 0;
74*a1a3b679SAndreas Boehler        foreach($r['aggregates'] as $priv) {
75*a1a3b679SAndreas Boehler
76*a1a3b679SAndreas Boehler            if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy') {
77*a1a3b679SAndreas Boehler                $ok++;
78*a1a3b679SAndreas Boehler            }
79*a1a3b679SAndreas Boehler            if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent') {
80*a1a3b679SAndreas Boehler                $ok++;
81*a1a3b679SAndreas Boehler            }
82*a1a3b679SAndreas Boehler        }
83*a1a3b679SAndreas Boehler
84*a1a3b679SAndreas Boehler        $this->assertEquals(2, $ok, "We're missing one or more privileges");
85*a1a3b679SAndreas Boehler
86*a1a3b679SAndreas Boehler    }
87*a1a3b679SAndreas Boehler
88*a1a3b679SAndreas Boehler
89*a1a3b679SAndreas Boehler}
90