1<?php
2
3namespace Sabre\DAVACL\FS;
4
5use Sabre\DAVACL\PrincipalBackend\Mock as PrincipalBackend;
6
7class HomeCollectionTest extends \PHPUnit_Framework_TestCase {
8
9    /**
10     * System under test
11     *
12     * @var HomeCollection
13     */
14    protected $sut;
15
16    protected $path;
17    protected $name = 'thuis';
18
19    function setUp() {
20
21        $principalBackend = new PrincipalBackend();
22
23        $this->path = SABRE_TEMPDIR . '/home';
24
25        $this->sut = new HomeCollection($principalBackend, $this->path);
26        $this->sut->collectionName = $this->name;
27
28
29    }
30
31    function tearDown() {
32
33        \Sabre\TestUtil::clearTempDir();
34
35    }
36
37    function testGetName() {
38
39        $this->assertEquals(
40            $this->name,
41            $this->sut->getName()
42        );
43
44    }
45
46    function testGetChild() {
47
48        $child = $this->sut->getChild('user1');
49        $this->assertInstanceOf('Sabre\\DAVACL\\FS\\Collection', $child);
50        $this->assertEquals('user1', $child->getName());
51
52        $owner = 'principals/user1';
53        $acl = [
54            [
55                'privilege' => '{DAV:}read',
56                'principal' => $owner,
57                'protected' => true,
58            ],
59            [
60                'privilege' => '{DAV:}write',
61                'principal' => $owner,
62                'protected' => true,
63            ],
64        ];
65
66        $this->assertEquals($acl, $child->getACL());
67        $this->assertEquals($owner, $child->getOwner());
68
69    }
70
71    function testGetOwner() {
72
73        $this->assertNull(
74            $this->sut->getOwner()
75        );
76
77    }
78
79    function testGetGroup() {
80
81        $this->assertNull(
82            $this->sut->getGroup()
83        );
84
85    }
86
87    function testGetACL() {
88
89        $acl = [
90            [
91                'principal' => '{DAV:}authenticated',
92                'privilege' => '{DAV:}read',
93                'protected' => true,
94            ]
95        ];
96
97        $this->assertEquals(
98            $acl,
99            $this->sut->getACL()
100        );
101
102    }
103
104    /**
105     * @expectedException \Sabre\DAV\Exception\Forbidden
106     */
107    function testSetAcl() {
108
109        $this->sut->setACL([]);
110
111    }
112
113    function testGetSupportedPrivilegeSet() {
114
115        $this->assertNull(
116            $this->sut->getSupportedPrivilegeSet()
117        );
118
119    }
120
121}
122