ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLSLPEventHandlerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
24{
25 public static function _refreshStatus(int $a_obj_id, ?array $a_users = null): void
26 {
27 throw new \Exception('Do not use ilLPStatusWrapper::_refreshStatus here; use _updateStatus instead');
28 }
29
30 public static function _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj = null, bool $a_percentage = false, bool $a_force_raise = false): void
31 {
32 }
33}
34
36{
40 protected function getRefIdsOfObjId(int $triggerer_obj_id): array
41 {
42 return [14, 20];
43 }
44}
45
46class ilLSLPEventHandlerTest extends TestCase
47{
48 protected ilTree $tree;
50
51 protected function setUp(): void
52 {
53 $this->tree = $this->createMock(ilTree::class);
54 $this->lp_status = new ilLPStatusWrapperStub();
55 }
56
57 public function testCreateObject(): void
58 {
59 $obj = new ilLSLPEventHandler($this->tree, $this->lp_status);
60
61 $this->assertInstanceOf(ilLSLPEventHandler::class, $obj);
62 }
63
64 public function testUpdateLPForChildEvent(): void
65 {
66 $values = [
67 'obj_id' => 12,
68 'usr_id' => 101
69 ];
70
71 $obj_id = 43;
72
73 $this->tree
74 ->expects($this->exactly(2))
75 ->method('getParentNodeData')
76 ->willReturn([
77 "type" => "lso",
78 "obj_id" => $obj_id
79 ])
80 ;
81
82 $obj = new ilLSLPEventHandlerStub($this->tree, $this->lp_status);
83 $obj->updateLPForChildEvent($values);
84 //do not call getParentNodeData again!
85 $obj->updateLPForChildEvent($values);
86 }
87}
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
Class ilLPStatusWrapper This class is wrapper for all ilLPStatus classes.
getRefIdsOfObjId(int $triggerer_obj_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...