aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php
blob: 594241e0d24b1d23ba7996309aaaa591814d1a98 (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
<?php

declare(strict_types=1);

namespace Sabre\CalDAV\Notifications;

use Sabre\CalDAV;

class CollectionTest extends \PHPUnit\Framework\TestCase
{
    protected $caldavBackend;
    protected $principalUri;
    protected $notification;

    public function getInstance()
    {
        $this->principalUri = 'principals/user1';

        $this->notification = new CalDAV\Xml\Notification\SystemStatus(1, '"1"');

        $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [
            'principals/user1' => [
                $this->notification,
            ],
        ]);

        return new Collection($this->caldavBackend, $this->principalUri);
    }

    public function testGetChildren()
    {
        $col = $this->getInstance();
        $this->assertEquals('notifications', $col->getName());

        $this->assertEquals([
            new Node($this->caldavBackend, $this->principalUri, $this->notification),
        ], $col->getChildren());
    }

    public function testGetOwner()
    {
        $col = $this->getInstance();
        $this->assertEquals('principals/user1', $col->getOwner());
    }

    public function testGetGroup()
    {
        $col = $this->getInstance();
        $this->assertNull($col->getGroup());
    }

    public function testGetACL()
    {
        $col = $this->getInstance();
        $expected = [
            [
                'privilege' => '{DAV:}all',
                'principal' => '{DAV:}owner',
                'protected' => true,
            ],
        ];

        $this->assertEquals($expected, $col->getACL());
    }

    public function testSetACL()
    {
        $this->expectException('Sabre\DAV\Exception\Forbidden');
        $col = $this->getInstance();
        $col->setACL([]);
    }

    public function testGetSupportedPrivilegeSet()
    {
        $col = $this->getInstance();
        $this->assertNull($col->getSupportedPrivilegeSet());
    }
}