ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserCertificateTableProviderTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27  {
28  $database = $this->getMockBuilder(ilDBInterface::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $database
33  ->expects($this->atLeastOnce())
34  ->method('quote');
35 
36  $database->method('fetchAssoc')
37  ->willReturnOnConsecutiveCalls(
38  [
39  'id' => 600,
40  'obj_id' => 100,
41  'title' => 'CourseTest',
42  'obj_type' => 'crs',
43  'acquired_timestamp' => 1_539_867_618,
44  'tile_image_path' => 'some/path/test.svg',
45  'tile_image_ident' => '-',
46  'description' => 'some description',
47  'firstname' => 'ilyas',
48  'lastname' => 'homer',
49  ],
50  null
51  );
52 
53  $logger = $this->getMockBuilder(ilLogger::class)
54  ->disableOriginalConstructor()
55  ->getMock();
56 
58  $database,
59  $logger,
60  'default_title'
61  );
62 
63  $dataSet = $provider->fetchDataSet(100, ['language' => 'de'], []);
64 
65  $expected = [];
66 
67  $expected['items'][] = [
68  'id' => 600,
69  'title' => 'CourseTest',
70  'obj_id' => 100,
71  'obj_type' => 'crs',
72  'date' => 1_539_867_618,
73  'tile_image_path' => 'some/path/test.svg',
74  'tile_image_ident' => '-',
75  'description' => 'some description',
76  'firstname' => 'ilyas',
77  'lastname' => 'homer',
78  ];
79 
80  $expected['cnt'] = 1;
81 
82  $this->assertSame($expected, $dataSet);
83  }
84 
86  {
87  $database = $this->createMock(ilDBInterface::class);
88 
89  $database
90  ->expects($this->atLeastOnce())
91  ->method('quote');
92 
93  $database->method('fetchAssoc')
94  ->willReturnOnConsecutiveCalls(
95  [
96  'id' => 600,
97  'obj_id' => 100,
98  'title' => 'CourseTest',
99  'obj_type' => 'crs',
100  'acquired_timestamp' => 1_539_867_618,
101  'tile_image_path' => 'some/path/test.svg',
102  'tile_image_ident' => '-',
103  'description' => 'some description',
104  'firstname' => 'ilyas',
105  'lastname' => 'homer',
106  ],
107  null,
108  [
109  'cnt' => 5,
110  ],
111  null
112  );
113 
114  $logger = $this->getMockBuilder(ilLogger::class)
115  ->disableOriginalConstructor()
116  ->getMock();
117 
119  $database,
120  $logger,
121  'default_title'
122  );
123 
124  $dataSet = $provider->fetchDataSet(100, ['language' => 'de', 'limit' => 2], []);
125 
126  $expected = [];
127 
128  $expected['items'][] = [
129  'id' => 600,
130  'title' => 'CourseTest',
131  'obj_id' => 100,
132  'obj_type' => 'crs',
133  'date' => 1_539_867_618,
134  'tile_image_path' => 'some/path/test.svg',
135  'tile_image_ident' => '-',
136  'description' => 'some description',
137  'firstname' => 'ilyas',
138  'lastname' => 'homer',
139  ];
140 
141  $expected['cnt'] = 5;
142 
143  $this->assertSame($expected, $dataSet);
144  }
145 
147  {
148  $database = $this->createMock(ilDBInterface::class);
149 
150  $database
151  ->expects($this->atLeastOnce())
152  ->method('quote');
153 
154  $database->method('fetchAssoc')
155  ->willReturnOnConsecutiveCalls(
156  [
157  'id' => 600,
158  'obj_id' => 100,
159  'title' => 'CourseTest',
160  'obj_type' => 'crs',
161  'acquired_timestamp' => 1_539_867_618,
162  'tile_image_path' => 'some/path/test.svg',
163  'tile_image_ident' => '-',
164  'description' => 'some description',
165  'firstname' => 'ilyas',
166  'lastname' => 'homer',
167  ],
168  null,
169  [
170  'cnt' => 5,
171  ],
172  null
173  );
174 
175  $logger = $this->getMockBuilder(ilLogger::class)
176  ->disableOriginalConstructor()
177  ->getMock();
178 
180  $database,
181  $logger,
182  'default_title'
183  );
184 
185  $dataSet = $provider->fetchDataSet(
186  100,
187  ['language' => 'de', 'limit' => 2, 'order_field' => 'date'],
188  []
189  );
190 
191  $expected = [];
192 
193  $expected['items'][] = [
194  'id' => 600,
195  'title' => 'CourseTest',
196  'obj_id' => 100,
197  'obj_type' => 'crs',
198  'date' => 1_539_867_618,
199  'tile_image_path' => 'some/path/test.svg',
200  'tile_image_ident' => '-',
201  'description' => 'some description',
202  'firstname' => 'ilyas',
203  'lastname' => 'homer',
204  ];
205 
206  $expected['cnt'] = 5;
207 
208  $this->assertSame($expected, $dataSet);
209  }
210 
212  {
213  $this->expectException(InvalidArgumentException::class);
214 
215  $database = $this->createMock(ilDBInterface::class);
216 
217  $database
218  ->expects($this->atLeastOnce())
219  ->method('quote');
220 
221  $database->method('fetchAssoc')
222  ->willReturnOnConsecutiveCalls(
223  [
224  'id' => 600,
225  'obj_id' => 100,
226  'title' => 'CourseTest',
227  'obj_type' => 'crs',
228  'acquired_timestamp' => 1_539_867_618
229  ],
230  null,
231  [
232  'cnt' => 5,
233  ],
234  null
235  );
236 
237  $logger = $this->getMockBuilder(ilLogger::class)
238  ->disableOriginalConstructor()
239  ->getMock();
240 
242  $database,
243  $logger,
244  'default_title'
245  );
246 
247  $provider->fetchDataSet(
248  100,
249  ['language' => 'de', 'limit' => 2, 'order_field' => 'something'],
250  []
251  );
252 
253  $this->fail('Should never happen');
254  }
255 
257  {
258  $this->expectException(InvalidArgumentException::class);
259 
260  $database = $this->createMock(ilDBInterface::class);
261 
262  $database
263  ->expects($this->atLeastOnce())
264  ->method('quote');
265 
266  $database->method('fetchAssoc')
267  ->willReturnOnConsecutiveCalls(
268  [
269  'id' => 600,
270  'obj_id' => 100,
271  'title' => 'CourseTest',
272  'obj_type' => 'crs',
273  'acquired_timestamp' => 1_539_867_618
274  ],
275  null,
276  [
277  'cnt' => 5,
278  ],
279  null
280  );
281 
282  $logger = $this->getMockBuilder(ilLogger::class)
283  ->disableOriginalConstructor()
284  ->getMock();
285 
287  $database,
288  $logger,
289  'default_title'
290  );
291 
292  $provider->fetchDataSet(
293  100,
294  ['language' => 'de', 'limit' => 2, 'order_field' => false],
295  []
296  );
297 
298  $this->fail('Should never happen');
299  }
300 
302  {
303  $this->expectException(InvalidArgumentException::class);
304 
305  $database = $this->createMock(ilDBInterface::class);
306 
307  $database
308  ->expects($this->atLeastOnce())
309  ->method('quote');
310 
311  $database->method('fetchAssoc')
312  ->willReturnOnConsecutiveCalls(
313  [
314  'id' => 600,
315  'obj_id' => 100,
316  'title' => 'CourseTest',
317  'obj_type' => 'crs',
318  'acquired_timestamp' => 1_539_867_618
319  ],
320  null,
321  [
322  'cnt' => 5,
323  ],
324  null
325  );
326 
327  $logger = $this->getMockBuilder(ilLogger::class)
328  ->disableOriginalConstructor()
329  ->getMock();
330 
332  $database,
333  $logger,
334  'default_title'
335  );
336 
337  $provider->fetchDataSet(
338  600,
339  [
340  'language' => 'de',
341  'limit' => 2,
342  'order_field' => 'date',
343  'order_direction' => 'mac'
344  ],
345  []
346  );
347 
348  $this->fail('Should never happen');
349  }
350 
352  {
353  $this->expectException(InvalidArgumentException::class);
354 
355  $database = $this->createMock(ilDBInterface::class);
356 
357  $database
358  ->expects($this->atLeastOnce())
359  ->method('quote');
360 
361  $database->method('fetchAssoc')
362  ->willReturnOnConsecutiveCalls(
363  [
364  'id' => 600,
365  'obj_id' => 100,
366  'title' => 'CourseTest',
367  'obj_type' => 'crs',
368  'acquired_timestamp' => 1_539_867_618
369  ],
370  null,
371  [
372  'cnt' => 5,
373  ],
374  null
375  );
376 
377  $logger = $this->getMockBuilder(ilLogger::class)
378  ->disableOriginalConstructor()
379  ->getMock();
380 
382  $database,
383  $logger,
384  'default_title'
385  );
386 
387  $provider->fetchDataSet(
388  600,
389  [
390  'language' => 'de',
391  'limit' => 'something',
392  'order_field' => 'date',
393  'order_direction' => 'mac'
394  ],
395  []
396  );
397 
398  $this->fail('Should never happen');
399  }
400 
402  {
403  $this->expectException(InvalidArgumentException::class);
404 
405  $database = $this->createMock(ilDBInterface::class);
406 
407  $database
408  ->expects($this->atLeastOnce())
409  ->method('quote');
410 
411  $database->method('fetchAssoc')
412  ->willReturnOnConsecutiveCalls(
413  [
414  'id' => 600,
415  'obj_id' => 100,
416  'title' => 'CourseTest',
417  'obj_type' => 'crs',
418  'acquired_timestamp' => 1_539_867_618
419  ],
420  null,
421  [
422  'cnt' => 5,
423  ],
424  null
425  );
426 
427  $logger = $this->getMockBuilder(ilLogger::class)
428  ->disableOriginalConstructor()
429  ->getMock();
430 
432  $database,
433  $logger,
434  'default_title'
435  );
436 
437  $provider->fetchDataSet(
438  600,
439  [
440  'limit' => 3,
441  'language' => 'de',
442  'order_field' => 'date',
443  'order_direction' => 'mac',
444  'offset' => 'something'
445  ],
446  []
447  );
448 
449  $this->fail('Should never happen');
450  }
451 }
Class ilCertificateBaseTestCase.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$provider
Definition: ltitoken.php:80