aboutsummaryrefslogblamecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php
blob: 6585f85c379090def784d444c25989b5a5627060 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                          
                                                                                 
 

                                                                       
                                   

             









                                                                         
                             
                                                                                    
                                



















                                                                  



                                             
                                    

              





                                                       
                                                        



                                    
                         









                                                            
<?php

namespace Sabre\CalDAV\Notifications;

use Sabre\CalDAV;

class CollectionTest extends \PHPUnit_Framework_TestCase {

    protected $caldavBackend;
    protected $principalUri;
    protected $notification;

    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);

    }

    function testGetChildren() {

        $col = $this->getInstance();
        $this->assertEquals('notifications', $col->getName());

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

    }

    function testGetOwner() {

        $col = $this->getInstance();
        $this->assertEquals('principals/user1', $col->getOwner());

    }

    function testGetGroup() {

        $col = $this->getInstance();
        $this->assertNull($col->getGroup());

    }

    function testGetACL() {

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

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

    }

    /**
     * @expectedException \Sabre\DAV\Exception\Forbidden
     */
    function testSetACL() {

        $col = $this->getInstance();
        $col->setACL([]);

    }

    function testGetSupportedPrivilegeSet() {

        $col = $this->getInstance();
        $this->assertNull($col->getSupportedPrivilegeSet());

    }
}