ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BasicNodeTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
6
10 function testPut() {
11
12 $file = new FileMock();
13 $file->put('hi');
14
15 }
16
20 function testGet() {
21
22 $file = new FileMock();
23 $file->get();
24
25 }
26
27 function testGetSize() {
28
29 $file = new FileMock();
30 $this->assertEquals(0, $file->getSize());
31
32 }
33
34
35 function testGetETag() {
36
37 $file = new FileMock();
38 $this->assertNull($file->getETag());
39
40 }
41
42 function testGetContentType() {
43
44 $file = new FileMock();
45 $this->assertNull($file->getContentType());
46
47 }
48
52 function testDelete() {
53
54 $file = new FileMock();
55 $file->delete();
56
57 }
58
62 function testSetName() {
63
64 $file = new FileMock();
65 $file->setName('hi');
66
67 }
68
70
71 $file = new FileMock();
72 // checking if lastmod is within the range of a few seconds
73 $lastMod = $file->getLastModified();
74 $compareTime = ($lastMod + 1) - time();
75 $this->assertTrue($compareTime < 3);
76
77 }
78
79 function testGetChild() {
80
81 $dir = new DirectoryMock();
82 $file = $dir->getChild('mockfile');
83 $this->assertTrue($file instanceof FileMock);
84
85 }
86
87 function testChildExists() {
88
89 $dir = new DirectoryMock();
90 $this->assertTrue($dir->childExists('mockfile'));
91
92 }
93
95
96 $dir = new DirectoryMock();
97 $this->assertFalse($dir->childExists('mockfile2'));
98
99 }
100
104 function testGetChild404() {
105
106 $dir = new DirectoryMock();
107 $file = $dir->getChild('blabla');
108
109 }
110
114 function testCreateFile() {
115
116 $dir = new DirectoryMock();
117 $dir->createFile('hello', 'data');
118
119 }
120
125
126 $dir = new DirectoryMock();
127 $dir->createDirectory('hello');
128
129 }
130
132
133 $dir = new SimpleCollection('simpledir', []);
134 $this->assertInstanceOf('Sabre\DAV\SimpleCollection', $dir);
135
136 }
137
142
143 $file = new FileMock();
144 $dir = new SimpleCollection('simpledir', [$file]);
145 $file2 = $dir->getChild('mockfile');
146
147 $this->assertEquals($file, $file2);
148
149 }
150
156
157 $dir = new SimpleCollection('simpledir', ['string shouldn\'t be here']);
158
159 }
160
165
166 $file = new FileMock();
167 $dir = new SimpleCollection('simpledir');
168 $dir->addChild($file);
169 $file2 = $dir->getChild('mockfile');
170
171 $this->assertEquals($file, $file2);
172
173 }
174
180
181 $file = new FileMock();
182 $dir = new SimpleCollection('simpledir');
183 $dir->addChild($file);
184
185 $this->assertEquals([$file], $dir->getChildren());
186
187 }
188
189 /*
190 * @depends testSimpleDirectoryConstruct
191 */
193
194 $dir = new SimpleCollection('simpledir');
195 $this->assertEquals('simpledir', $dir->getName());
196
197 }
198
204
205 $dir = new SimpleCollection('simpledir');
206 $dir->getChild('blabla');
207
208 }
209}
210
212
213 function getName() {
214
215 return 'mockdir';
216
217 }
218
219 function getChildren() {
220
221 return [new FileMock()];
222
223 }
224
225}
226
227class FileMock extends File {
228
229 function getName() {
230
231 return 'mockfile';
232
233 }
234
235}
An exception for terminatinating execution or to throw for unit testing.
testSimpleDirectoryConstructChild()
@depends testSimpleDirectoryConstruct
testSimpleDirectoryGetChild404()
@depends testSimpleDirectoryConstruct @expectedException Sabre\DAV\Exception\NotFound
testSimpleDirectoryGetChildren()
@depends testSimpleDirectoryConstruct @depends testSimpleDirectoryAddChild
testGetChild404()
@expectedException Sabre\DAV\Exception\NotFound
testCreateDirectory()
@expectedException Sabre\DAV\Exception\Forbidden
testPut()
@expectedException Sabre\DAV\Exception\Forbidden
testSimpleDirectoryAddChild()
@depends testSimpleDirectoryConstruct
testCreateFile()
@expectedException Sabre\DAV\Exception\Forbidden
testGet()
@expectedException Sabre\DAV\Exception\Forbidden
testDelete()
@expectedException Sabre\DAV\Exception\Forbidden
testSetName()
@expectedException Sabre\DAV\Exception\Forbidden
testSimpleDirectoryBadParam()
@expectedException Sabre\DAV\Exception @depends testSimpleDirectoryConstruct
Collection class.
Definition: Collection.php:15
getChildren()
Returns an array with all the child nodes.
getName()
Returns the name of the node.
getName()
Returns the name of the node.
File class.
Definition: File.php:15