ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FreeBusyDataTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
5use PHPUnit\Framework\TestCase;
6
7class FreeBusyDataTest extends TestCase {
8
9 function testGetData() {
10
11 $fb = new FreeBusyData(100, 200);
12
13 $this->assertEquals(
14 [
15 [
16 'start' => 100,
17 'end' => 200,
18 'type' => 'FREE',
19 ]
20 ],
21 $fb->getData()
22 );
23
24 }
25
29 function testAddBeginning() {
30
31 $fb = new FreeBusyData(100, 200);
32
33 // Overwriting the first half
34 $fb->add(100, 150, 'BUSY');
35
36
37 $this->assertEquals(
38 [
39 [
40 'start' => 100,
41 'end' => 150,
42 'type' => 'BUSY',
43 ],
44 [
45 'start' => 150,
46 'end' => 200,
47 'type' => 'FREE',
48 ]
49 ],
50 $fb->getData()
51 );
52
53 // Overwriting the first half again
54 $fb->add(100, 150, 'BUSY-TENTATIVE');
55
56 $this->assertEquals(
57 [
58 [
59 'start' => 100,
60 'end' => 150,
61 'type' => 'BUSY-TENTATIVE',
62 ],
63 [
64 'start' => 150,
65 'end' => 200,
66 'type' => 'FREE',
67 ]
68 ],
69 $fb->getData()
70 );
71
72 }
73
77 function testAddEnd() {
78
79 $fb = new FreeBusyData(100, 200);
80
81 // Overwriting the first half
82 $fb->add(150, 200, 'BUSY');
83
84
85 $this->assertEquals(
86 [
87 [
88 'start' => 100,
89 'end' => 150,
90 'type' => 'FREE',
91 ],
92 [
93 'start' => 150,
94 'end' => 200,
95 'type' => 'BUSY',
96 ],
97 ],
98 $fb->getData()
99 );
100
101
102 }
103
107 function testAddMiddle() {
108
109 $fb = new FreeBusyData(100, 200);
110
111 // Overwriting the first half
112 $fb->add(150, 160, 'BUSY');
113
114
115 $this->assertEquals(
116 [
117 [
118 'start' => 100,
119 'end' => 150,
120 'type' => 'FREE',
121 ],
122 [
123 'start' => 150,
124 'end' => 160,
125 'type' => 'BUSY',
126 ],
127 [
128 'start' => 160,
129 'end' => 200,
130 'type' => 'FREE',
131 ],
132 ],
133 $fb->getData()
134 );
135
136 }
137
141 function testAddMultiple() {
142
143 $fb = new FreeBusyData(100, 200);
144
145 $fb->add(110, 120, 'BUSY');
146 $fb->add(130, 140, 'BUSY');
147
148 $this->assertEquals(
149 [
150 [
151 'start' => 100,
152 'end' => 110,
153 'type' => 'FREE',
154 ],
155 [
156 'start' => 110,
157 'end' => 120,
158 'type' => 'BUSY',
159 ],
160 [
161 'start' => 120,
162 'end' => 130,
163 'type' => 'FREE',
164 ],
165 [
166 'start' => 130,
167 'end' => 140,
168 'type' => 'BUSY',
169 ],
170 [
171 'start' => 140,
172 'end' => 200,
173 'type' => 'FREE',
174 ],
175 ],
176 $fb->getData()
177 );
178
179 }
180
185
186 $fb = new FreeBusyData(100, 200);
187
188 $fb->add(110, 120, 'BUSY');
189 $fb->add(130, 140, 'BUSY');
190
191 $this->assertEquals(
192 [
193 [
194 'start' => 100,
195 'end' => 110,
196 'type' => 'FREE',
197 ],
198 [
199 'start' => 110,
200 'end' => 120,
201 'type' => 'BUSY',
202 ],
203 [
204 'start' => 120,
205 'end' => 130,
206 'type' => 'FREE',
207 ],
208 [
209 'start' => 130,
210 'end' => 140,
211 'type' => 'BUSY',
212 ],
213 [
214 'start' => 140,
215 'end' => 200,
216 'type' => 'FREE',
217 ],
218 ],
219 $fb->getData()
220 );
221
222 $fb->add(115, 135, 'BUSY-TENTATIVE');
223
224 $this->assertEquals(
225 [
226 [
227 'start' => 100,
228 'end' => 110,
229 'type' => 'FREE',
230 ],
231 [
232 'start' => 110,
233 'end' => 115,
234 'type' => 'BUSY',
235 ],
236 [
237 'start' => 115,
238 'end' => 135,
239 'type' => 'BUSY-TENTATIVE',
240 ],
241 [
242 'start' => 135,
243 'end' => 140,
244 'type' => 'BUSY',
245 ],
246 [
247 'start' => 140,
248 'end' => 200,
249 'type' => 'FREE',
250 ],
251 ],
252 $fb->getData()
253 );
254 }
255
260
261 $fb = new FreeBusyData(100, 200);
262
263 $fb->add(110, 120, 'BUSY');
264 $fb->add(130, 140, 'BUSY');
265
266 $this->assertEquals(
267 [
268 [
269 'start' => 100,
270 'end' => 110,
271 'type' => 'FREE',
272 ],
273 [
274 'start' => 110,
275 'end' => 120,
276 'type' => 'BUSY',
277 ],
278 [
279 'start' => 120,
280 'end' => 130,
281 'type' => 'FREE',
282 ],
283 [
284 'start' => 130,
285 'end' => 140,
286 'type' => 'BUSY',
287 ],
288 [
289 'start' => 140,
290 'end' => 200,
291 'type' => 'FREE',
292 ],
293 ],
294 $fb->getData()
295 );
296
297 $fb->add(115, 135, 'BUSY');
298
299 $this->assertEquals(
300 [
301 [
302 'start' => 100,
303 'end' => 110,
304 'type' => 'FREE',
305 ],
306 [
307 'start' => 110,
308 'end' => 140,
309 'type' => 'BUSY',
310 ],
311 [
312 'start' => 140,
313 'end' => 200,
314 'type' => 'FREE',
315 ],
316 ],
317 $fb->getData()
318 );
319 }
320}
An exception for terminatinating execution or to throw for unit testing.
testAddMiddle()
@depends testAddEnd
testAddMultipleOverlapAndMerge()
@depends testAddMultipleOverlap
testAddBeginning()
@depends testGetData
testAddMultiple()
@depends testAddMiddle
testAddEnd()
@depends testAddBeginning
testAddMultipleOverlap()
@depends testAddMultiple
FreeBusyData is a helper class that manages freebusy information.