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
119 ->expects($this->once())
120 ->method('clear')
121 ;
122
123 $consecutive = [
124 [100, 'visible', '', 33],
125 [100, 'read', '', 33]
126 ];
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
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 }