ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestParticipantListTest Class Reference

Class ilTestParticipantListTest. More...

+ Inheritance diagram for ilTestParticipantListTest:
+ Collaboration diagram for ilTestParticipantListTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 testAddParticipant ()
 
 testGetParticipantByUsrId ()
 
 testHasUnfinishedPasses ()
 
 testGetAllUserIds ()
 
 testGetAllActiveIds ()
 
 testIsActiveIdInList ()
 
 testGetAccessFilteredList ()
 
 testCurrent ()
 
 testNext ()
 
 testKey ()
 
 testValid ()
 
 testRewind ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilTestBaseTestCase
 setUp ()
 
 tearDown ()
 

Private Attributes

ilTestParticipantList $testObj
 

Additional Inherited Members

- Static Public Member Functions inherited from ilTestBaseTestCase
static callMethod ($obj, $name, array $args=[])
 
- Protected Attributes inherited from ilTestBaseTestCase
Container $dic = null
 

Detailed Description

Member Function Documentation

◆ setUp()

ilTestParticipantListTest::setUp ( )
protected

Definition at line 29 of file ilTestParticipantListTest.php.

References $DIC.

29  : void
30  {
31  global $DIC;
32  parent::setUp();
33 
34  $this->addGlobal_ilUser();
35 
36  $this->testObj = new ilTestParticipantList(
37  $this->getTestObjMock(),
38  $DIC['ilUser'],
39  $DIC['lng'],
40  $DIC['ilDB'],
41  );
42  }
global $DIC
Definition: shib_login.php:22

◆ test_instantiateObject_shouldReturnInstance()

ilTestParticipantListTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 44 of file ilTestParticipantListTest.php.

44  : void
45  {
46  $this->assertInstanceOf(ilTestParticipantList::class, $this->testObj);
47  }

◆ testAddParticipant()

ilTestParticipantListTest::testAddParticipant ( )

Definition at line 49 of file ilTestParticipantListTest.php.

49  : void
50  {
51  $activeId = 22;
52  $participant = new ilTestParticipant();
53  $participant->setActiveId($activeId);
54  $this->testObj->addParticipant($participant);
55  $this->assertEquals($participant, $this->testObj->getParticipantByActiveId($activeId));
56  }

◆ testCurrent()

ilTestParticipantListTest::testCurrent ( )

Definition at line 169 of file ilTestParticipantListTest.php.

References $id.

169  : void
170  {
171  $ids = [
172  12,
173  125,
174  176
175  ];
176 
177  foreach ($ids as $id) {
178  $participant = new ilTestParticipant();
179  $participant->setUsrId($id);
180  $this->testObj->addParticipant($participant);
181  }
182 
183  if (isset($ids[0])) {
184  $this->assertEquals($ids[0], $this->testObj->current()->getUsrId());
185  } else {
186  $this->assertTrue(false);
187  }
188  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetAccessFilteredList()

ilTestParticipantListTest::testGetAccessFilteredList ( )

Definition at line 138 of file ilTestParticipantListTest.php.

References $id.

138  : void
139  {
140  $ids = [
141  12,
142  125,
143  176,
144  12111,
145  1
146  ];
147 
148  $expected = [
149  12,
150  125,
151  176
152  ];
153 
154  foreach ($ids as $id) {
155  $participant = new ilTestParticipant();
156  $participant->setUsrId($id);
157  $this->testObj->addParticipant($participant);
158  }
159 
160  $callback = static function ($userIds) use ($expected) {
161  return $expected;
162  };
163 
164  foreach ($expected as $value) {
165  $this->assertInstanceOf(ilTestParticipant::class, $this->testObj->getAccessFilteredList($callback)->getParticipantByUsrId($value));
166  }
167  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetAllActiveIds()

ilTestParticipantListTest::testGetAllActiveIds ( )

Definition at line 100 of file ilTestParticipantListTest.php.

References $id.

100  : void
101  {
102  $ids = [
103  12,
104  125,
105  176,
106  12111,
107  1
108  ];
109 
110  foreach ($ids as $id) {
111  $participant = new ilTestParticipant();
112  $participant->setActiveId($id);
113  $this->testObj->addParticipant($participant);
114  }
115  $this->assertEquals($ids, $this->testObj->getAllActiveIds());
116  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetAllUserIds()

ilTestParticipantListTest::testGetAllUserIds ( )

Definition at line 82 of file ilTestParticipantListTest.php.

References $id.

82  : void
83  {
84  $ids = [
85  12,
86  125,
87  176,
88  12111,
89  1
90  ];
91 
92  foreach ($ids as $id) {
93  $participant = new ilTestParticipant();
94  $participant->setUsrId($id);
95  $this->testObj->addParticipant($participant);
96  }
97  $this->assertEquals($ids, $this->testObj->getAllUserIds());
98  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testGetParticipantByUsrId()

ilTestParticipantListTest::testGetParticipantByUsrId ( )

Definition at line 58 of file ilTestParticipantListTest.php.

58  : void
59  {
60  $usr_id = 125;
61  $participant = new ilTestParticipant();
62  $participant->setUsrId($usr_id);
63  $this->testObj->addParticipant($participant);
64  $this->assertEquals($participant, $this->testObj->getParticipantByUsrId($usr_id));
65  }

◆ testHasUnfinishedPasses()

ilTestParticipantListTest::testHasUnfinishedPasses ( )

Definition at line 67 of file ilTestParticipantListTest.php.

67  : void
68  {
69  $participant = new ilTestParticipant();
70  $participant->setUnfinishedPasses(false);
71  $this->testObj->addParticipant($participant);
72 
73  $this->assertFalse($this->testObj->hasUnfinishedPasses());
74 
75  $participant = new ilTestParticipant();
76  $participant->setUnfinishedPasses(true);
77  $this->testObj->addParticipant($participant);
78 
79  $this->assertTrue($this->testObj->hasUnfinishedPasses());
80  }

◆ testIsActiveIdInList()

ilTestParticipantListTest::testIsActiveIdInList ( )

Definition at line 118 of file ilTestParticipantListTest.php.

References $id.

118  : void
119  {
120  $ids = [
121  12,
122  125,
123  176,
124  12111,
125  1
126  ];
127 
128  foreach ($ids as $id) {
129  $participant = new ilTestParticipant();
130  $participant->setActiveId($id);
131  $this->testObj->addParticipant($participant);
132 
133  $this->assertTrue($this->testObj->isActiveIdInList($id));
134  }
135  $this->assertFalse($this->testObj->isActiveIdInList(PHP_INT_MAX));
136  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testKey()

ilTestParticipantListTest::testKey ( )

Definition at line 214 of file ilTestParticipantListTest.php.

References $id.

214  : void
215  {
216  $ids = [
217  12,
218  125,
219  176
220  ];
221 
222  foreach ($ids as $key => $id) {
223  $participant = new ilTestParticipant();
224  $participant->setUsrId($id);
225  $this->testObj->addParticipant($participant);
226 
227  $this->assertEquals($key, $this->testObj->key());
228  $this->testObj->next();
229  }
230  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testNext()

ilTestParticipantListTest::testNext ( )

Definition at line 190 of file ilTestParticipantListTest.php.

References $id.

190  : void
191  {
192  $ids = [
193  12,
194  125,
195  176
196  ];
197 
198  foreach ($ids as $id) {
199  $participant = new ilTestParticipant();
200  $participant->setUsrId($id);
201  $this->testObj->addParticipant($participant);
202  }
203 
204  $countIds = count($ids);
205  if ($countIds > 0) {
206  for ($i = 1; $i < $countIds; $i++) {
207  $this->testObj->next();
208  }
209 
210  $this->assertEquals($ids[--$countIds], $this->testObj->current()->getUsrId());
211  }
212  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testRewind()

ilTestParticipantListTest::testRewind ( )

Definition at line 255 of file ilTestParticipantListTest.php.

References $id.

255  : void
256  {
257  $ids = [
258  12,
259  125,
260  176
261  ];
262 
263  foreach ($ids as $id) {
264  $participant = new ilTestParticipant();
265  $participant->setUsrId($id);
266  $this->testObj->addParticipant($participant);
267  }
268 
269  $countIds = count($ids);
270  if ($countIds > 0) {
271  for ($i = 1; $i < $countIds; $i++) {
272  $this->testObj->next();
273  }
274  $this->assertTrue($this->testObj->valid());
275 
276  $this->testObj->rewind();
277  $this->assertEquals($ids[0], $this->testObj->current()->getUsrId());
278  } else {
279  $this->assertTrue(false);
280  }
281  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ testValid()

ilTestParticipantListTest::testValid ( )

Definition at line 232 of file ilTestParticipantListTest.php.

References $id.

232  : void
233  {
234  $ids = [
235  12,
236  125,
237  176
238  ];
239 
240  foreach ($ids as $id) {
241  $participant = new ilTestParticipant();
242  $participant->setUsrId($id);
243  $this->testObj->addParticipant($participant);
244  }
245 
246  for ($i = 0, $iMax = count($ids) - 1; $i < $iMax; $i++) {
247  $this->testObj->next();
248  }
249  $this->assertTrue($this->testObj->valid());
250 
251  $this->testObj->next();
252  $this->assertFalse($this->testObj->valid());
253  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

Field Documentation

◆ $testObj

ilTestParticipantList ilTestParticipantListTest::$testObj
private

Definition at line 27 of file ilTestParticipantListTest.php.


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