aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php
blob: 623525e69d90af743c5e71292f89ce2f0ffe5632 (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
79
80
81
82
83
84
85
86
87
88
<?php

declare(strict_types=1);

namespace Sabre\CalDAV\Notifications;

use Sabre\CalDAV;

class NodeTest extends \PHPUnit\Framework\TestCase
{
    protected $systemStatus;
    protected $caldavBackend;

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

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

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

        $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus);

        return $node;
    }

    public function testGetId()
    {
        $node = $this->getInstance();
        $this->assertEquals($this->systemStatus->getId().'.xml', $node->getName());
    }

    public function testGetEtag()
    {
        $node = $this->getInstance();
        $this->assertEquals('"1"', $node->getETag());
    }

    public function testGetNotificationType()
    {
        $node = $this->getInstance();
        $this->assertEquals($this->systemStatus, $node->getNotificationType());
    }

    public function testDelete()
    {
        $node = $this->getInstance();
        $node->delete();
        $this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1'));
    }

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

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

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

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

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