ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLearnerProgressDBTest Class Reference
+ Inheritance diagram for ilLearnerProgressDBTest:
+ Collaboration diagram for ilLearnerProgressDBTest:

Public Member Functions

 testCreateObject ()
 
 testGetLearnerItemsWithoutData ()
 
 testGetLearnerItemsWithNonVisibleLSItem ()
 
 testGetLearnerItemsWithVisibleLSItem ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

ilLSItemsDB $items_db
 
ilAccess $access
 
ilObjectDataCache $obj_data_cache
 

Detailed Description

Definition at line 31 of file ilLearnerProgressDBTest.php.

Member Function Documentation

◆ setUp()

ilLearnerProgressDBTest::setUp ( )
protected

Definition at line 37 of file ilLearnerProgressDBTest.php.

37 : void
38 {
39 $this->items_db = $this->createMock(ilLSItemsDB::class);
40 $this->access = $this->createMock(ilAccess::class);
41 $this->obj_data_cache = $this->createMock(ilObjectDataCache::class);
42 }

References ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ testCreateObject()

ilLearnerProgressDBTest::testCreateObject ( )

Definition at line 44 of file ilLearnerProgressDBTest.php.

44 : void
45 {
46 $obj = new ilLearnerProgressDB($this->items_db, $this->access, $this->obj_data_cache);
47
48 $this->assertInstanceOf(ilLearnerProgressDB::class, $obj);
49 }
Get LearningProgress and availability of items in sequence.

References ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ testGetLearnerItemsWithNonVisibleLSItem()

ilLearnerProgressDBTest::testGetLearnerItemsWithNonVisibleLSItem ( )

Definition at line 67 of file ilLearnerProgressDBTest.php.

67 : void
68 {
69 $ls_item = $this->createMock(LSItem::class);
70
71 $ls_item
72 ->expects($this->once())
73 ->method('isOnline')
74 ->willReturn(false)
75 ;
76 $ls_item
77 ->expects($this->once())
78 ->method('getRefId')
79 ->willReturn(33)
80 ;
81
82 $this->access
83 ->expects($this->once())
84 ->method('checkAccessOfUser')
85 ->with(100, 'visible', '', 33)
86 ->willReturn(false)
87 ;
88
89 $this->items_db
90 ->expects($this->once())
91 ->method('getLSItems')
92 ->with(44)
93 ->willReturn([$ls_item])
94 ;
95
96 $obj = new ilLearnerProgressDB($this->items_db, $this->access, $this->obj_data_cache);
97 $result = $obj->getLearnerItems(100, 44);
98
99 $this->assertIsArray($result);
100 $this->assertEmpty($result);
101 }

References ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ testGetLearnerItemsWithoutData()

ilLearnerProgressDBTest::testGetLearnerItemsWithoutData ( )

Definition at line 51 of file ilLearnerProgressDBTest.php.

51 : void
52 {
53 $this->items_db
54 ->expects($this->once())
55 ->method('getLsItems')
56 ->with(33)
57 ->willReturn([])
58 ;
59
60 $obj = new ilLearnerProgressDB($this->items_db, $this->access, $this->obj_data_cache);
61 $result = $obj->getLearnerItems(100, 33);
62
63 $this->assertIsArray($result);
64 $this->assertEmpty($result);
65 }

References ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ testGetLearnerItemsWithVisibleLSItem()

ilLearnerProgressDBTest::testGetLearnerItemsWithVisibleLSItem ( )

Definition at line 103 of file ilLearnerProgressDBTest.php.

103 : void
104 {
105 $ls_item = $this->createMock(LSItem::class);
106
107 $ls_item
108 ->expects($this->exactly(2))
109 ->method('isOnline')
110 ->willReturn(true)
111 ;
112 $ls_item
113 ->expects($this->exactly(3))
114 ->method('getRefId')
115 ->willReturn(33)
116 ;
117
118 $this->access
119 ->expects($this->once())
120 ->method('clear')
121 ;
122
123 $consecutive = [
124 [100, 'visible', '', 33],
125 [100, 'read', '', 33]
126 ];
127 $this->access
128 ->expects($this->exactly(2))
129 ->method('checkAccessOfUser')
130 ->willReturnCallback(
131 function ($uid, $perm, $cmd, $ref_id) use (&$consecutive) {
132 $expected = array_shift($consecutive);
133 $this->assertEquals($expected, [$uid, $perm, $cmd, $ref_id]);
134 return true;
135 }
136 );
137 ;
138
139 $this->items_db
140 ->expects($this->once())
141 ->method('getLSItems')
142 ->with(44)
143 ->willReturn([$ls_item])
144 ;
145
146 $obj = new ilLearnerProgressDBStub($this->items_db, $this->access, $this->obj_data_cache);
147 $result = $obj->getLearnerItems(100, 44);
148
149 foreach ($result as $ls_learner_item) {
150 $this->assertInstanceOf(LSLearnerItem::class, $ls_learner_item);
151 $this->assertEquals(33, $ls_learner_item->getRefId());
152 $this->assertEquals(20, $ls_learner_item->getLearningProgressStatus());
153 $this->assertEquals(1, $ls_learner_item->getAvailability());
154 }
155 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, and ILIAS\Repository\access().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccess ilLearnerProgressDBTest::$access
protected

Definition at line 34 of file ilLearnerProgressDBTest.php.

◆ $items_db

ilLSItemsDB ilLearnerProgressDBTest::$items_db
protected

Definition at line 33 of file ilLearnerProgressDBTest.php.

◆ $obj_data_cache

ilObjectDataCache ilLearnerProgressDBTest::$obj_data_cache
protected

Definition at line 35 of file ilLearnerProgressDBTest.php.


The documentation for this class was generated from the following file: