ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLSLPEventHandlerTest.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 2021 - Daniel Weise <daniel.weise@concepts-and-training.de> - Extended GPL, see LICENSE */
4
5use PHPUnit\Framework\TestCase;
6
8{
9 public static function _refreshStatus($a_obj_id, $a_users = null)
10 {
11 throw new \Exception('Do not use ilLPStatusWrapper::_refreshStatus here; use _updateStatus instead');
12 }
13 public static function _updateStatus($a_obj_id, $a_user)
14 {
15 }
16}
17
19{
23 protected function getRefIdsOfObjId(int $triggerer_obj_id) : array
24 {
25 return [14, 20];
26 }
27}
28
29class ilLSLPEventHandlerTest extends TestCase
30{
34 protected $tree;
35
39 protected $lp_status;
40
41 protected function setUp() : void
42 {
43 $this->tree = $this->createMock(ilTree::class);
44 $this->lp_status = new ilLPStatusWrapperStub();
45 }
46
47 public function testCreateObject() : void
48 {
49 $obj = new ilLSLPEventHandler($this->tree, $this->lp_status);
50
51 $this->assertInstanceOf(ilLSLPEventHandler::class, $obj);
52 }
53
54 public function testUpdateLPForChildEvent() : void
55 {
56 $values = [
57 'obj_id' => 12,
58 'usr_id' => 101
59 ];
60
61 $obj_id = 43;
62
63 $this->tree
64 ->expects($this->exactly(2))
65 ->method('getParentNodeData')
66 ->willReturn(['type' => 'lso', 'obj_id'=>$obj_id])
67 ;
68
69 $obj = new ilLSLPEventHandlerStub($this->tree, $this->lp_status);
70 $obj->updateLPForChildEvent($values);
71 //do not call getParentNodeData again!
72 $obj->updateLPForChildEvent($values);
73 }
74}
An exception for terminatinating execution or to throw for unit testing.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static _updateStatus($a_obj_id, $a_user)
Class ilLPStatusWrapper This class is wrapper for all ilLPStatus classes.
getRefIdsOfObjId(int $triggerer_obj_id)