]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAVACL/AllowAccessTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAVACL / AllowAccessTest.php
1 <?php
2
3 class Sabre_DAVACL_AllowAccessTest extends PHPUnit_Framework_TestCase {
4
5     /**
6      * @var Sabre_DAV_Server
7      */
8     protected $server;
9
10     function setUp() {
11
12         $nodes = array(
13             new Sabre_DAV_SimpleCollection('testdir'),
14         );
15
16         $this->server = new Sabre_DAV_Server($nodes);
17         $aclPlugin = new Sabre_DAVACL_Plugin();
18         $aclPlugin->allowAccessToNodesWithoutACL = true;
19         $this->server->addPlugin($aclPlugin);
20
21     }
22
23     function testGet() {
24
25         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('GET','testdir')));
26
27     }
28
29     function testGetDoesntExist() {
30
31         $r = $this->server->broadcastEvent('beforeMethod',array('GET','foo'));
32         $this->assertTrue($r);
33
34     }
35
36     function testHEAD() {
37
38         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('HEAD','testdir')));
39
40     }
41
42     function testOPTIONS() {
43
44         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('OPTIONS','testdir')));
45
46     }
47
48     function testPUT() {
49
50         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PUT','testdir')));
51
52     }
53
54     function testACL() {
55
56         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('ACL','testdir')));
57
58     }
59
60     function testPROPPATCH() {
61
62         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PROPPATCH','testdir')));
63
64     }
65
66     function testCOPY() {
67
68         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('COPY','testdir')));
69
70     }
71
72     function testMOVE() {
73
74         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('MOVE','testdir')));
75
76     }
77
78     function testLOCK() {
79
80         $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('LOCK','testdir')));
81
82     }
83
84     function testBeforeBind() {
85
86         $this->assertTrue($this->server->broadcastEvent('beforeBind',array('testdir/file')));
87
88     }
89
90
91     function testBeforeUnbind() {
92
93         $this->assertTrue($this->server->broadcastEvent('beforeUnbind',array('testdir')));
94
95     }
96
97     function testAfterGetProperties() {
98
99         $properties = array(
100             'href' => 'foo',
101             '200' => array(
102                 '{DAV:}displayname' => 'foo',
103                 '{DAV:}getcontentlength' => 500,
104             ),
105             '404' => array(
106                 '{DAV:}bar' => null,
107             ),
108             '403' => array(
109                 '{DAV:}owner' => null,
110             ),
111         );
112
113         $expected = array(
114             'href' => 'foo',
115             '200' => array(
116                 '{DAV:}displayname' => 'foo',
117                 '{DAV:}getcontentlength' => 500,
118             ),
119             '404' => array(
120                 '{DAV:}bar' => null,
121             ),
122             '403' => array(
123                 '{DAV:}owner' => null,
124             ),
125         );
126
127         $r = $this->server->broadcastEvent('afterGetProperties',array('testdir',&$properties));
128         $this->assertTrue($r);
129
130         $this->assertEquals($expected, $properties);
131
132     }
133
134 }