ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PluginTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV\Sharing;
4
7
9
10 protected $setupSharing = true;
11 protected $setupACL = true;
12 protected $autoLogin = 'admin';
13
14 function setUpTree() {
15
16 $this->tree[] = new Mock\SharedNode(
17 'shareable',
19 );
20
21 }
22
23 function testFeatures() {
24
25 $this->assertEquals(
26 ['resource-sharing'],
27 $this->sharingPlugin->getFeatures()
28 );
29
30 }
31
32 function testProperties() {
33
34 $result = $this->server->getPropertiesForPath(
35 'shareable',
36 ['{DAV:}share-access']
37 );
38
39 $expected = [
40 [
41 200 => [
42 '{DAV:}share-access' => new Property\ShareAccess(Plugin::ACCESS_READWRITE)
43 ],
44 404 => [],
45 'href' => 'shareable',
46 ]
47 ];
48
49 $this->assertEquals(
50 $expected,
52 );
53
54 }
55
56 function testGetPluginInfo() {
57
58 $result = $this->sharingPlugin->getPluginInfo();
59 $this->assertInternalType('array', $result);
60 $this->assertEquals('sharing', $result['name']);
61
62 }
63
65
66 $node = new \Sabre\DAV\Mock\Collection('foo');
67 $html = '';
68
69 $this->assertNull(
70 $this->sharingPlugin->htmlActionsPanel($node, $html, 'foo/bar')
71 );
72
73 $this->assertEquals(
74 '',
75 $html
76 );
77
78 $node = new \Sabre\DAV\Mock\SharedNode('foo', \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER);
79 $html = '';
80
81 $this->assertNull(
82 $this->sharingPlugin->htmlActionsPanel($node, $html, 'shareable')
83 );
84 $this->assertContains(
85 'Share this resource',
86 $html
87 );
88
89 }
90
92
93 $this->assertNull($this->sharingPlugin->browserPostAction(
94 'shareable',
95 'foo',
96 []
97 ));
98
99 }
100
102
103 $this->assertFalse($this->sharingPlugin->browserPostAction(
104 'shareable',
105 'share',
106 [
107 'access' => 'read',
108 'href' => 'mailto:foo@example.org',
109 ]
110 ));
111
112 $expected = [
113 new \Sabre\DAV\Xml\Element\Sharee([
114 'href' => 'mailto:foo@example.org',
115 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ,
116 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
117 ])
118 ];
119 $this->assertEquals(
120 $expected,
121 $this->tree[0]->getInvites()
122 );
123
124 }
125
130
131 $this->sharingPlugin->browserPostAction(
132 'shareable',
133 'share',
134 [
135 'access' => 'read',
136 ]
137 );
138
139 }
140
145
146 $this->sharingPlugin->browserPostAction(
147 'shareable',
148 'share',
149 [
150 'href' => 'mailto:foo@example.org',
151 ]
152 );
153
154 }
155
156
161
162 $this->sharingPlugin->browserPostAction(
163 'shareable',
164 'share',
165 [
166 'href' => 'mailto:foo@example.org',
167 'access' => 'bleed',
168 ]
169 );
170
171 }
172
177
178 $this->aclPlugin->setDefaultAcl([]);
179 $this->sharingPlugin->browserPostAction(
180 'shareable',
181 'share',
182 [
183 'access' => 'read',
184 'href' => 'mailto:foo@example.org',
185 ]
186 );
187
188 }
189
190}
$result
An exception for terminatinating execution or to throw for unit testing.
This class may be used as a basis for other webdav-related unittests.
testBrowserPostActionNoAccess()
@expectedException \Sabre\DAV\Exception\BadRequest
Definition: PluginTest.php:144
testBrowserPostActionAccessDenied()
@expectedException \Sabre\DAV\Exception\Forbidden
Definition: PluginTest.php:176
testBrowserPostActionNoHref()
@expectedException \Sabre\DAV\Exception\BadRequest
Definition: PluginTest.php:129
setUpTree()
Override this to provide your own Tree for your test-case.
Definition: PluginTest.php:14
testBrowserPostActionBadAccess()
@expectedException \Sabre\DAV\Exception\BadRequest
Definition: PluginTest.php:160
$html
Definition: example_001.php:87