ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilIndividualAssessmentMemberTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
29  private $iass_object;
33  private $grading;
37  private $obj_user;
38 
39  protected function setUp(): void
40  {
41  $this->iass_object = $this->createMock(ilObjIndividualAssessment::class);
42  $this->grading = $this->createMock(ilIndividualAssessmentUserGrading::class);
43  $this->obj_user = $this->createMock(ilObjUser::class);
44  }
45 
46  public function test_createObject(): void
47  {
49  $this->iass_object,
50  $this->obj_user,
51  $this->grading,
52  22222
53  );
54 
55  $this->assertInstanceOf(ilIndividualAssessmentMember::class, $obj);
56  }
57 
58  public function test_getRecord(): void
59  {
60  $this->grading
61  ->expects($this->once())
62  ->method("getRecord")
63  ->willReturn("testRecord")
64  ;
65 
67  $this->iass_object,
68  $this->obj_user,
69  $this->grading,
70  22222
71  );
72 
73  $this->assertEquals("testRecord", $obj->record());
74  }
75 
76  public function test_internalNote(): void
77  {
78  $this->grading
79  ->expects($this->once())
80  ->method("getInternalNote")
81  ->willReturn("internalNote")
82  ;
83 
85  $this->iass_object,
86  $this->obj_user,
87  $this->grading,
88  22222
89  );
90 
91  $this->assertEquals("internalNote", $obj->internalNote());
92  }
93 
94  public function test_examinerId_not_set(): void
95  {
97  $this->iass_object,
98  $this->obj_user,
99  $this->grading,
100  22222
101  );
102 
103  $this->assertNull($obj->examinerId());
104  }
105 
106  public function test_examinerId(): void
107  {
108  $obj = new ilIndividualAssessmentMember(
109  $this->iass_object,
110  $this->obj_user,
111  $this->grading,
112  22222,
113  3434
114  );
115 
116  $this->assertEquals(3434, $obj->examinerId());
117  }
118 
119  public function test_changerId_not_set(): void
120  {
121  $obj = new ilIndividualAssessmentMember(
122  $this->iass_object,
123  $this->obj_user,
124  $this->grading,
125  22222
126  );
127 
128  $this->assertNull($obj->changerId());
129  }
130 
131  public function test_changerId(): void
132  {
133  $obj = new ilIndividualAssessmentMember(
134  $this->iass_object,
135  $this->obj_user,
136  $this->grading,
137  22222,
138  0,
139  5656
140  );
141 
142  $this->assertEquals(5656, $obj->changerId());
143  }
144 
145  public function test_changeTime_not_set(): void
146  {
147  $obj = new ilIndividualAssessmentMember(
148  $this->iass_object,
149  $this->obj_user,
150  $this->grading,
151  22222
152  );
153 
154  $this->assertNull($obj->changeTime());
155  }
156 
157  public function test_changeTime(): void
158  {
159  $obj = new ilIndividualAssessmentMember(
160  $this->iass_object,
161  $this->obj_user,
162  $this->grading,
163  22222,
164  0,
165  0,
166  new DateTimeImmutable('2021-11-25')
167  );
168 
169  $this->assertEquals('2021-11-25', $obj->changeTime()->format('Y-m-d'));
170  }
171 
172  public function test_notify(): void
173  {
174  $this->grading
175  ->expects($this->once())
176  ->method("isNotify")
177  ->willReturn(true)
178  ;
179 
180  $obj = new ilIndividualAssessmentMember(
181  $this->iass_object,
182  $this->obj_user,
183  $this->grading,
184  22222
185  );
186 
187  $this->assertTrue($obj->notify());
188  }
189 
191  {
192  $notificator = $this->createMock(ilIndividualAssessmentNotificator::class);
193 
194  $this->grading
195  ->expects($this->once())
196  ->method("isFinalized")
197  ->willReturn(false)
198  ;
199 
200  $obj = new ilIndividualAssessmentMember(
201  $this->iass_object,
202  $this->obj_user,
203  $this->grading,
204  22222
205  );
206 
207  $this->expectException(ilIndividualAssessmentException::class);
208  $this->expectExceptionMessage('must finalize before notification');
209  $obj->maybeSendNotification($notificator);
210  }
211 
213  {
214  $notificator = $this->createMock(ilIndividualAssessmentNotificator::class);
215 
216  $this->grading
217  ->expects($this->once())
218  ->method("isFinalized")
219  ->willReturn(true)
220  ;
221  $this->grading
222  ->expects($this->once())
223  ->method("isNotify")
224  ->willReturn(false)
225  ;
226 
227  $obj = new ilIndividualAssessmentMember(
228  $this->iass_object,
229  $this->obj_user,
230  $this->grading,
231  22222
232  );
233 
234  $this->assertEquals($obj, $obj->maybeSendNotification($notificator));
235  }
236 
237  public function test_id(): void
238  {
239  $this->obj_user
240  ->expects($this->once())
241  ->method("getId")
242  ->willReturn(22)
243  ;
244 
245  $obj = new ilIndividualAssessmentMember(
246  $this->iass_object,
247  $this->obj_user,
248  $this->grading,
249  22222
250  );
251 
252  $this->assertEquals(22, $obj->id());
253  }
254 
255  public function test_assessmentId(): void
256  {
257  $this->iass_object
258  ->expects($this->once())
259  ->method("getId")
260  ->willReturn(22)
261  ;
262 
263  $obj = new ilIndividualAssessmentMember(
264  $this->iass_object,
265  $this->obj_user,
266  $this->grading,
267  22222
268  );
269 
270  $this->assertEquals(22, $obj->assessmentId());
271  }
272 
273  public function test_assessment(): void
274  {
275  $obj = new ilIndividualAssessmentMember(
276  $this->iass_object,
277  $this->obj_user,
278  $this->grading,
279  22222
280  );
281 
282  $this->assertEquals($this->iass_object, $obj->assessment());
283  }
284 
285  public function test_finalized(): void
286  {
287  $this->grading
288  ->expects($this->once())
289  ->method("isFinalized")
290  ->willReturn(true)
291  ;
292 
293  $obj = new ilIndividualAssessmentMember(
294  $this->iass_object,
295  $this->obj_user,
296  $this->grading,
297  22222
298  );
299 
300  $this->assertTrue($obj->finalized());
301  }
302 
303  public static function fileNamesDataProvider(): array
304  {
305  return [
306  [''],
307  [null]
308  ];
309  }
310 
311  #[\PHPUnit\Framework\Attributes\DataProvider('fileNamesDataProvider')]
313  {
314  $settings = $this->createMock(ilIndividualAssessmentSettings::class);
315  $settings
316  ->expects($this->once())
317  ->method("isFileRequired")
318  ->willReturn(true)
319  ;
320 
321  $this->iass_object
322  ->expects($this->once())
323  ->method("getSettings")
324  ->willReturn($settings)
325  ;
326 
327  $this->grading
328  ->expects($this->once())
329  ->method("getFile")
330  ->willReturn($filename)
331  ;
332 
333  $obj = new ilIndividualAssessmentMember(
334  $this->iass_object,
335  $this->obj_user,
336  $this->grading,
337  22222
338  );
339 
340  $this->assertFalse($obj->mayBeFinalized());
341  }
342 
343  public static function positiveLPStatusDataProvider(): array
344  {
345  return [
348  ];
349  }
350 
351  #[\PHPUnit\Framework\Attributes\DataProvider('positiveLPStatusDataProvider')]
352  public function test_mayBeFinalized_with_positive_lp_status(int $lp_status): void
353  {
354  $settings = $this->createMock(ilIndividualAssessmentSettings::class);
355  $settings
356  ->expects($this->once())
357  ->method("isFileRequired")
358  ->willReturn(false)
359  ;
360 
361  $this->iass_object
362  ->expects($this->once())
363  ->method("getSettings")
364  ->willReturn($settings)
365  ;
366 
367  $this->grading
368  ->expects($this->once())
369  ->method("getLearningProgress")
370  ->willReturn($lp_status)
371  ;
372  $this->grading
373  ->expects($this->once())
374  ->method("isFinalized")
375  ->willReturn(false)
376  ;
377 
378  $obj = new ilIndividualAssessmentMember(
379  $this->iass_object,
380  $this->obj_user,
381  $this->grading,
382  22222
383  );
384 
385  $this->assertTrue($obj->mayBeFinalized());
386  }
387 
389  {
390  $settings = $this->createMock(ilIndividualAssessmentSettings::class);
391  $settings
392  ->expects($this->once())
393  ->method("isFileRequired")
394  ->willReturn(false)
395  ;
396 
397  $this->iass_object
398  ->expects($this->once())
399  ->method("getSettings")
400  ->willReturn($settings)
401  ;
402 
403  $this->grading
404  ->expects($this->once())
405  ->method("getLearningProgress")
407  ;
408  $this->grading
409  ->expects($this->once())
410  ->method("isFinalized")
411  ->willReturn(true)
412  ;
413 
414  $obj = new ilIndividualAssessmentMember(
415  $this->iass_object,
416  $this->obj_user,
417  $this->grading,
418  22222
419  );
420 
421  $this->assertFalse($obj->mayBeFinalized());
422  }
423 
424  public static function negativeLPStatusDataProvider(): array
425  {
426  return [
429  ];
430  }
431 
432  #[\PHPUnit\Framework\Attributes\DataProvider('negativeLPStatusDataProvider')]
433  public function test_mayBeFinalized_with_negative_lp_status(int $lp_status): void
434  {
435  $settings = $this->createMock(ilIndividualAssessmentSettings::class);
436  $settings
437  ->expects($this->once())
438  ->method("isFileRequired")
439  ->willReturn(false)
440  ;
441 
442  $this->iass_object
443  ->expects($this->once())
444  ->method("getSettings")
445  ->willReturn($settings)
446  ;
447 
448  $this->grading
449  ->expects($this->once())
450  ->method("getLearningProgress")
451  ->willReturn($lp_status)
452  ;
453 
454  $obj = new ilIndividualAssessmentMember(
455  $this->iass_object,
456  $this->obj_user,
457  $this->grading,
458  22222
459  );
460 
461  $this->assertFalse($obj->mayBeFinalized());
462  }
463 
464  public function test_withExaminerId(): void
465  {
466  $obj = new ilIndividualAssessmentMember(
467  $this->iass_object,
468  $this->obj_user,
469  $this->grading,
470  22222
471  );
472 
473  $new_obj = $obj->withExaminerId(333);
474 
475  $this->assertNull($obj->examinerId());
476  $this->assertEquals(333, $new_obj->examinerId());
477  }
478 
479  public function test_withChangerId(): void
480  {
481  $obj = new ilIndividualAssessmentMember(
482  $this->iass_object,
483  $this->obj_user,
484  $this->grading,
485  22222
486  );
487 
488  $new_obj = $obj->withChangerId(534);
489 
490  $this->assertNull($obj->changerId());
491  $this->assertEquals(534, $new_obj->changerId());
492  }
493 
494  public function test_withChangeTime(): void
495  {
496  $obj = new ilIndividualAssessmentMember(
497  $this->iass_object,
498  $this->obj_user,
499  $this->grading,
500  22222
501  );
502 
503  $new_obj = $obj->withChangeTime(new DateTimeImmutable("2021-11-25"));
504 
505  $this->assertNull($obj->changeTime());
506  $this->assertEquals("2021-11-25", $new_obj->changeTime()->format("Y-m-d"));
507  }
508 
509  public function test_lastname(): void
510  {
511  $this->obj_user
512  ->expects($this->once())
513  ->method("getLastname")
514  ->willReturn("lastname")
515  ;
516 
517  $obj = new ilIndividualAssessmentMember(
518  $this->iass_object,
519  $this->obj_user,
520  $this->grading,
521  22222
522  );
523 
524  $this->assertEquals("lastname", $obj->lastname());
525  }
526 
527  public function test_firstname(): void
528  {
529  $this->obj_user
530  ->expects($this->once())
531  ->method("getFirstname")
532  ->willReturn("firstname")
533  ;
534 
535  $obj = new ilIndividualAssessmentMember(
536  $this->iass_object,
537  $this->obj_user,
538  $this->grading,
539  22222
540  );
541 
542  $this->assertEquals("firstname", $obj->firstname());
543  }
544 
545  public function test_login(): void
546  {
547  $this->obj_user
548  ->expects($this->once())
549  ->method("getLogin")
550  ->willReturn("login")
551  ;
552 
553  $obj = new ilIndividualAssessmentMember(
554  $this->iass_object,
555  $this->obj_user,
556  $this->grading,
557  22222
558  );
559 
560  $this->assertEquals("login", $obj->login());
561  }
562 
563  public function test_name(): void
564  {
565  $this->obj_user
566  ->expects($this->once())
567  ->method("getFullName")
568  ->willReturn("first last")
569  ;
570 
571  $obj = new ilIndividualAssessmentMember(
572  $this->iass_object,
573  $this->obj_user,
574  $this->grading,
575  22222
576  );
577 
578  $this->assertEquals("first last", $obj->name());
579  }
580 
581  public function test_LPStatus(): void
582  {
583  $this->grading
584  ->expects($this->once())
585  ->method("getLearningProgress")
587  ;
588 
589  $obj = new ilIndividualAssessmentMember(
590  $this->iass_object,
591  $this->obj_user,
592  $this->grading,
593  22222
594  );
595 
596  $this->assertEquals(ilIndividualAssessmentMembers::LP_COMPLETED, $obj->LPStatus());
597  }
598 
599  public function test_notificationTS(): void
600  {
601  $obj = new ilIndividualAssessmentMember(
602  $this->iass_object,
603  $this->obj_user,
604  $this->grading,
605  22222
606  );
607 
608  $this->assertEquals(22222, $obj->notificationTS());
609  }
610 
611  public function test_place(): void
612  {
613  $this->grading
614  ->expects($this->once())
615  ->method("getPlace")
616  ->willReturn("place")
617  ;
618 
619  $obj = new ilIndividualAssessmentMember(
620  $this->iass_object,
621  $this->obj_user,
622  $this->grading,
623  22222
624  );
625 
626  $this->assertEquals("place", $obj->place());
627  }
628 
629  public function test_eventTime(): void
630  {
631  $this->grading
632  ->expects($this->once())
633  ->method("getEventTime")
634  ->willReturn(new DateTimeImmutable("2021-11-25"))
635  ;
636 
637  $obj = new ilIndividualAssessmentMember(
638  $this->iass_object,
639  $this->obj_user,
640  $this->grading,
641  22222
642  );
643 
644  $this->assertEquals("2021-11-25", $obj->eventTime()->format("Y-m-d"));
645  }
646 
647  public function test_fileName(): void
648  {
649  $this->grading
650  ->expects($this->once())
651  ->method("getFile")
652  ->willReturn("file_name")
653  ;
654 
655  $obj = new ilIndividualAssessmentMember(
656  $this->iass_object,
657  $this->obj_user,
658  $this->grading,
659  22222
660  );
661 
662  $this->assertEquals("file_name", $obj->fileName());
663  }
664 
665  public function test_viewFile(): void
666  {
667  $this->grading
668  ->expects($this->once())
669  ->method("isFileVisible")
670  ->willReturn(true)
671  ;
672 
673  $obj = new ilIndividualAssessmentMember(
674  $this->iass_object,
675  $this->obj_user,
676  $this->grading,
677  22222
678  );
679 
680  $this->assertTrue($obj->viewFile());
681  }
682 
683  public function test_getGrading(): void
684  {
685  $obj = new ilIndividualAssessmentMember(
686  $this->iass_object,
687  $this->obj_user,
688  $this->grading,
689  22222
690  );
691 
692  $this->assertEquals($this->grading, $obj->getGrading());
693  }
694 
695  public function test_withGrading(): void
696  {
697  $obj = new ilIndividualAssessmentMember(
698  $this->iass_object,
699  $this->obj_user,
700  $this->grading,
701  22222
702  );
703 
704  $new_grading = $this->createMock(ilIndividualAssessmentUserGrading::class);
705  $new_grading = $new_grading->withFinalized(true);
706  $new_obj = $obj->withGrading($new_grading);
707 
708  $this->assertNotEquals($new_grading, $obj->getGrading());
709  $this->assertEquals($new_grading, $new_obj->getGrading());
710  }
711 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$filename
Definition: buildRTE.php:78
Edit the record of a user, set LP.