ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilIndividualAssessmentMembersTest Class Reference

disabled needsInstalledILIAS More...

+ Inheritance diagram for ilIndividualAssessmentMembersTest:
+ Collaboration diagram for ilIndividualAssessmentMembersTest:

Public Member Functions

 setUp ()
 
 createUser ()
 
 test_init_iass ()
 
 test_create_members ($args)
 test_init_iass More...
 
 test_load_members ($args)
 test_create_members More...
 
 test_load_member ($args)
 test_load_members More...
 
 test_reload_member ($args)
 test_load_member More...
 
 test_remove_members ($args)
 test_reload_member More...
 
 test_finalize_nongraded ($args)
 test_remove_members ilIndividualAssessmentException More...
 
 test_finalize_graded ($args)
 test_remove_members More...
 
 test_re_grade ($args)
 test_finalize_graded ilIndividualAssessmentException More...
 
 test_re_finalize ($args)
 test_finalize_graded ilIndividualAssessmentException More...
 
 test_withOnlyUsersByIds ()
 
 test_withAccessHandling ()
 

Static Public Member Functions

static tearDownAfterClass ()
 

Static Public Attributes

static $iass
 
static $created_users = array()
 

Protected Member Functions

 compareMembersUsrList ($members, $usr_list)
 
 rbacHandlerMock ()
 
 notificaterMock ()
 

Detailed Description

disabled needsInstalledILIAS

Definition at line 21 of file ilIndividualAssessmentMembersTest.php.

Member Function Documentation

◆ compareMembersUsrList()

ilIndividualAssessmentMembersTest::compareMembersUsrList (   $members,
  $usr_list 
)
protected

Definition at line 44 of file ilIndividualAssessmentMembersTest.php.

References array, ilIndividualAssessmentMembers\count(), ilIndividualAssessmentSettings\DEF_RECORD_TEMPLATE, and ilIndividualAssessmentMembers\FIELD_RECORD.

45  {
46  $usr_it = array();
47 
48 
49  foreach ($members as $member_id => $member_data) {
51  $usr_it[] = $member_id;
52  $this->assertTrue(isset($usr_list[$member_id]));
53  }
54  return;
55  foreach ($usr_list as $usr_id => $usr) {
56  $this->assertTrue($members->userAllreadyMember($usr));
57  }
58  $this->assertEquals(count($usr_it), count($usr_list));
59  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ createUser()

ilIndividualAssessmentMembersTest::createUser ( )

Definition at line 32 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\count(), ilObjUser\setFirstname(), and time.

33  {
34  $user = new ilObjUser;
35  $user->setFirstname('iass_test_firstname' . (count(self::$created_users)+time()));
36  $user->setLastname('iass_test_lastname' . (count(self::$created_users)+time()));
37  $user->setLogin('iass_tesst_login' . (count(self::$created_users)+time()));
38  $user->create();
39  $user->saveAsNew();
40  self::$created_users[] = $user;
41  return $user;
42  }
setFirstname($a_str)
set firstname public
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ notificaterMock()

ilIndividualAssessmentMembersTest::notificaterMock ( )
protected

Definition at line 66 of file ilIndividualAssessmentMembersTest.php.

67  {
68  return $this->createMock('ilIndividualAssessmentNotificator');
69  }

◆ rbacHandlerMock()

ilIndividualAssessmentMembersTest::rbacHandlerMock ( )
protected

Definition at line 61 of file ilIndividualAssessmentMembersTest.php.

62  {
63  return $this->createMock('IndividualAssessmentAccessHandler');
64  }

◆ setUp()

ilIndividualAssessmentMembersTest::setUp ( )

Definition at line 26 of file ilIndividualAssessmentMembersTest.php.

27  {
28  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29  ilUnitUtil::performInitialisation();
30  }

◆ tearDownAfterClass()

static ilIndividualAssessmentMembersTest::tearDownAfterClass ( )
static

Definition at line 292 of file ilIndividualAssessmentMembersTest.php.

References $ilDB.

293  {
294  global $ilDB;
295  foreach (self::$created_users as $user) {
296  $user->delete;
297  $ilDB->manipulate('DELETE FROM iass_settings WHERE obj_id = 100000000');
298  $ilDB->manipulate('DELETE FROM iass_info_settings WHERE obj_id = 100000000');
299  $ilDB->manipulate('DELETE FROM iass_members WHERE obj_id = 100000000');
300  }
301  }
global $ilDB

◆ test_create_members()

ilIndividualAssessmentMembersTest::test_create_members (   $args)

test_init_iass

Definition at line 85 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, and array.

86  {
87  $iass = $args[0];
88  $storage = $args[1];
89  $members = $storage->loadMembers($iass);
90 
91  $usr_1 = $this->createUser();
92  $usr_2 = $this->createUser();
93 
94  $usrs = array($usr_1->getId() => $usr_1,$usr_2->getId() => $usr_2);
95  $members = $members->withAdditionalUser($usr_1)->withAdditionalUser($usr_2);
96  $members->updateStorageAndRBAC($storage, $this->rbacHandlerMock());
97  $this->compareMembersUsrList($members, $usrs);
98 
99  return array($usrs,$iass,$storage);
100  }
Create styles array
The data for the language used.

◆ test_finalize_graded()

ilIndividualAssessmentMembersTest::test_finalize_graded (   $args)

test_remove_members

Definition at line 189 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, array, ilIndividualAssessmentMembers\current(), and ilIndividualAssessmentMembers\LP_COMPLETED.

190  {
191  $usrs = $args[0];
192  $iass = $args[1];
193  $storage = $args[2];
194  $storage->updateMember($storage->loadMember($iass, current($usrs))->withLPStatus(ilIndividualAssessmentMembers::LP_COMPLETED)->withFinalized());
195  $this->assertEquals($storage->loadMember($iass, current($usrs))->LPStatus(), ilIndividualAssessmentMembers::LP_COMPLETED);
196  $this->assertTrue($storage->loadMember($iass, current($usrs))->finalized());
197  return array($usrs,$iass,$storage);
198  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ test_finalize_nongraded()

ilIndividualAssessmentMembersTest::test_finalize_nongraded (   $args)

test_remove_members ilIndividualAssessmentException

Definition at line 178 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, and ilIndividualAssessmentMembers\current().

179  {
180  $usrs = $args[0];
181  $iass = $args[1];
182  $storage = $args[2];
183  $member = $storage->loadMember($iass, current($usrs))->withFinalized();
184  }
+ Here is the call graph for this function:

◆ test_init_iass()

ilIndividualAssessmentMembersTest::test_init_iass ( )

Definition at line 71 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, $ilDB, and array.

72  {
74  $iass ->setTitle("iass_test");
75  $iass ->setDescription("iass_test_desc");
76  $iass ->setId(100000000);
77  global $ilDB;
78  $storage = new ilIndividualAssessmentMembersStorageDB($ilDB);
79  return array($iass,$storage);
80  }
For the purpose of streamlining the grading and learning-process status definition outside of tests...
Create styles array
The data for the language used.
global $ilDB

◆ test_load_member()

ilIndividualAssessmentMembersTest::test_load_member (   $args)

test_load_members

Definition at line 118 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, array, and ilIndividualAssessmentSettings\DEF_RECORD_TEMPLATE.

119  {
120  $usrs = $args[0];
121  $iass = $args[1];
122  $storage = $args[2];
123  foreach ($usrs as $usr_id => $usr) {
124  $member = $storage->loadMember($iass, $usr);
125  $this->assertEquals($usr_id, $member->id());
126  $this->assertEquals($member->record(), ilIndividualAssessmentSettings::DEF_RECORD_TEMPLATE);
127  $this->assertEquals($member->lastname(), $usr->getLastname());
128  $member = $member->withRecord("record_of" . $usr_id);
129  $storage->updateMember($member);
130  }
131  return array($usrs,$iass,$storage);
132  }
Create styles array
The data for the language used.

◆ test_load_members()

ilIndividualAssessmentMembersTest::test_load_members (   $args)

test_create_members

Definition at line 105 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, and array.

106  {
107  $usrs = $args[0];
108  $iass = $args[1];
109  $storage = $args[2];
110  $members = $storage->loadMembers($iass);
111  $this->compareMembersUsrList($members, $usrs);
112  return array($usrs,$iass,$storage);
113  }
Create styles array
The data for the language used.

◆ test_re_finalize()

ilIndividualAssessmentMembersTest::test_re_finalize (   $args)

test_finalize_graded ilIndividualAssessmentException

Definition at line 216 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, and ilIndividualAssessmentMembers\current().

217  {
218  $usrs = $args[0];
219  $iass = $args[1];
220  $storage = $args[2];
221  $storage->loadMember($iass, current($usrs))->withFinalized();
222  }
+ Here is the call graph for this function:

◆ test_re_grade()

ilIndividualAssessmentMembersTest::test_re_grade (   $args)

test_finalize_graded ilIndividualAssessmentException

Definition at line 204 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, ilIndividualAssessmentMembers\current(), and ilIndividualAssessmentMembers\LP_COMPLETED.

205  {
206  $usrs = $args[0];
207  $iass = $args[1];
208  $storage = $args[2];
209  $storage->loadMember($iass, current($usrs))->withLPStatus(ilIndividualAssessmentMembers::LP_COMPLETED);
210  }
+ Here is the call graph for this function:

◆ test_reload_member()

ilIndividualAssessmentMembersTest::test_reload_member (   $args)

test_load_member

Definition at line 137 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, array, and ilIndividualAssessmentSettings\DEF_RECORD_TEMPLATE.

138  {
139  $usrs = $args[0];
140  $iass = $args[1];
141  $storage = $args[2];
142  foreach ($usrs as $usr_id => $usr) {
143  $member = $storage->loadMember($iass, $usr);
144  $this->assertEquals($usr_id, $member->id());
145  $this->assertEquals($member->record(), "record_of" . $usr_id);
146  $this->assertEquals($member->lastname(), $usr->getLastname());
147  $member = $member->withRecord(ilIndividualAssessmentSettings::DEF_RECORD_TEMPLATE);
148  $storage->updateMember($member);
149  }
150  return array($usrs,$iass,$storage);
151  }
Create styles array
The data for the language used.

◆ test_remove_members()

ilIndividualAssessmentMembersTest::test_remove_members (   $args)

test_reload_member

Definition at line 156 of file ilIndividualAssessmentMembersTest.php.

References ilIndividualAssessmentMembers\$iass, and array.

157  {
158  $usrs = $args[0];
159  $iass = $args[1];
160  $storage = $args[2];
161  $new_usr = $this->createUser();
162  $members = $storage->loadMembers($iass)->withAdditionalUser($new_usr);
163  $members->updateStorageAndRBAC($storage, $this->rbacHandlerMock());
164  $members = $storage->loadMembers($iass);
165  $usrs[$new_usr->getId()] = $new_usr;
166  $this->compareMembersUsrList($members, $usrs);
167  $members->withoutPresentUser($new_usr)->updateStorageAndRBAC($storage, $this->rbacHandlerMock());
168  $members = $storage->loadMembers($iass);
169  unset($usrs[$new_usr->getId()]);
170  $this->compareMembersUsrList($members, $usrs);
171  return array($usrs,$iass,$storage);
172  }
Create styles array
The data for the language used.

◆ test_withAccessHandling()

ilIndividualAssessmentMembersTest::test_withAccessHandling ( )

Definition at line 242 of file ilIndividualAssessmentMembersTest.php.

243  {
244  $ah = $this
245  ->getMockBuilder(\ilOrgUnitPositionAndRBACAccessHandler::class)
246  ->setMethods(["filterUserIdsByRbacOrPositionOfCurrentUser", "checkRbacOrPositionPermissionAccess"])
247  ->getMock();
248 
249  $obj = $this
250  ->getMockBuilder(\ilObjIndividualAssessment::class)
251  ->disableOriginalConstructor()
252  ->setMethods(["getRefId"])
253  ->getMock();
254 
255  $members = $this
256  ->getMockBuilder(\ilIndividualAssessmentMembers::class)
257  ->setMethods(["withOnlyUsersByIds", "membersIds", "referencedObject"])
258  ->disableOriginalConstructor()
259  ->getMock();
260 
261  $ref_id = 1985;
262 
263  $obj->method("getRefId")->willReturn($ref_id);
264 
265  $user_ids = [1,2,3,23,42,1337];
266  $keep_user_ids = [3, 23];
267 
268  $members
269  ->expects($this->once())
270  ->method("membersIds")
271  ->willReturn($user_ids);
272 
273  $members
274  ->expects($this->once())
275  ->method("referencedObject")
276  ->willReturn($obj);
277 
278  $ah
279  ->expects($this->once())
280  ->method("filterUserIdsByRbacOrPositionOfCurrentUser")
281  ->with("read_learning_progress", "read_learning_progress", $ref_id, $user_ids)
282  ->willReturn($keep_user_ids);
283 
284  $members
285  ->expects($this->once())
286  ->method("withOnlyUsersByIds")
287  ->with($keep_user_ids);
288 
289  $members->withAccessHandling($ah);
290  }

◆ test_withOnlyUsersByIds()

ilIndividualAssessmentMembersTest::test_withOnlyUsersByIds ( )

Definition at line 224 of file ilIndividualAssessmentMembersTest.php.

References $records.

225  {
226  $obj = $this
227  ->getMockBuilder(\ilObjIndividualAssessment::class)
228  ->disableOriginalConstructor()
229  ->getMock();
230 
231  $members = new RiggedMembers($obj);
232 
233  $records = [1 => 1, 2 => 2, 3 => 3, 23 => 23, 42 => 42, 1337 => 1337];
234 
235  $members->setMemberRecords($records);
236 
237  $members = $members->withOnlyUsersByIds([3,42]);
238 
239  $this->assertEquals([3, 42], $members->membersIds());
240  }
$records
Definition: simple_test.php:22

Field Documentation

◆ $created_users

ilIndividualAssessmentMembersTest::$created_users = array()
static

Definition at line 24 of file ilIndividualAssessmentMembersTest.php.

◆ $iass

ilIndividualAssessmentMembersTest::$iass
static

Definition at line 23 of file ilIndividualAssessmentMembersTest.php.


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