ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPrgRestartAssignmentsCronJobTest Class Reference

needsInstalledILIAS More...

+ Inheritance diagram for ilPrgRestartAssignmentsCronJobTest:
+ Collaboration diagram for ilPrgRestartAssignmentsCronJobTest:

Public Member Functions

 setUp ()
 
 test_init ()
 
 test_run ($job)
 test_init More...
 

Static Public Member Functions

static setUpBeforeClass ()
 
static tearDownAfterClass ()
 

Protected Member Functions

 newUser ()
 
 newPrg ()
 

Protected Attributes

 $backupGlobals = false
 
 $assignment_repo
 

Static Protected Attributes

static $instances = []
 
static $users = []
 

Detailed Description

needsInstalledILIAS

Definition at line 6 of file ilPrgRestartAssignmentsCronJobTest.php.

Member Function Documentation

◆ newPrg()

ilPrgRestartAssignmentsCronJobTest::newPrg ( )
protected

Definition at line 120 of file ilPrgRestartAssignmentsCronJobTest.php.

References ilObjStudyProgramme\createInstance().

Referenced by test_run().

121  {
123 
124 
125  self::$instances[] = $prg;
126  return $prg;
127  }
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newUser()

ilPrgRestartAssignmentsCronJobTest::newUser ( )
protected

Definition at line 112 of file ilPrgRestartAssignmentsCronJobTest.php.

Referenced by test_run().

113  {
114  $user = new ilObjUser();
115  $user->create();
116  self::$users[] = $user;
117  return $user;
118  }
+ Here is the caller graph for this function:

◆ setUp()

ilPrgRestartAssignmentsCronJobTest::setUp ( )

Definition at line 29 of file ilPrgRestartAssignmentsCronJobTest.php.

References ilStudyProgrammeDIC\dic().

29  : void
30  {
31  $this->assignment_repo =
32  ilStudyProgrammeDIC::dic()['model.Assignment.ilStudyProgrammeAssignmentRepository'];
33  }
+ Here is the call graph for this function:

◆ setUpBeforeClass()

static ilPrgRestartAssignmentsCronJobTest::setUpBeforeClass ( )
static

Definition at line 15 of file ilPrgRestartAssignmentsCronJobTest.php.

References $DIC, and Vendor\Package\$e.

15  : void
16  {
17  PHPUnit_Framework_Error_Deprecated::$enabled = false;
18 
19  global $DIC;
20  if (!$DIC) {
21  try {
22  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
23  ilUnitUtil::performInitialisation();
24  } catch (Exception $e) {
25  }
26  }
27  }
$DIC
Definition: xapitoken.php:46

◆ tearDownAfterClass()

static ilPrgRestartAssignmentsCronJobTest::tearDownAfterClass ( )
static

Definition at line 98 of file ilPrgRestartAssignmentsCronJobTest.php.

References Vendor\Package\$e.

98  : void
99  {
100  foreach (self::$instances as $instance) {
101  try {
102  $instance->delete();
103  } catch (Exception $e) {
104  }
105  }
106  foreach (self::$users as $user) {
107  $user->delete();
108  }
109  }

◆ test_init()

ilPrgRestartAssignmentsCronJobTest::test_init ( )

Definition at line 35 of file ilPrgRestartAssignmentsCronJobTest.php.

36  {
37  $job = new ilPrgRestartAssignmentsCronJob();
38  $this->assertInstanceOf(ilCronJob::class, $job);
39  return $job;
40  }

◆ test_run()

ilPrgRestartAssignmentsCronJobTest::test_run (   $job)

test_init

Definition at line 45 of file ilPrgRestartAssignmentsCronJobTest.php.

References newPrg(), newUser(), and ilStudyProgrammeSettings\STATUS_ACTIVE.

46  {
47  $usr1 = $this->newUser();
48  $usr2 = $this->newUser();
49  $usr3 = $this->newUser();
50  $usr4 = $this->newUser();
51 
52  $prg = $this->newPrg();
53  $prg->putInTree(ROOT_FOLDER_ID);
55  $prg->update();
56 
57  $assignment1 = $prg->assignUser($usr1->getId(), 6);
58  $assignment2 = $prg->assignUser($usr2->getId(), 6);
59  $assignment2_r = $assignment2->restartAssignment();
60  $assignment3 = $prg->assignUser($usr3->getId(), 6);
61  $assignment4 = $prg->assignUser($usr4->getId(), 6);
62 
63  $this->assertCount(1, $prg->getAssignmentsOf($usr1->getId()));
64  $this->assertCount(2, $prg->getAssignmentsOf($usr2->getId()));
65  $this->assertCount(1, $prg->getAssignmentsOf($usr3->getId()));
66  $this->assertCount(1, $prg->getAssignmentsOf($usr4->getId()));
67 
68  $yesterday = new DateTime();
69  $yesterday->sub(new DateInterval('P1D'));
70  $tomorrow = new DateTime();
71  $tomorrow->add(new DateInterval('P1D'));
72 
73  $m_ass1 = $this->assignment_repo->read($assignment1->getId());
74  $this->assignment_repo->update($m_ass1->setRestartDate($yesterday));
75  $m_ass2 = $this->assignment_repo->read($assignment2->getId());
76  $this->assignment_repo->update($m_ass2->setRestartDate($yesterday));
77  $m_ass3 = $this->assignment_repo->read($assignment3->getId());
78  $this->assignment_repo->update($m_ass3->setRestartDate($tomorrow));
79 
80  $job->run();
81 
82  $this->assertCount(2, $prg->getAssignmentsOf($usr1->getId()));
83  $this->assertCount(2, $prg->getAssignmentsOf($usr2->getId()));
84  $this->assertCount(1, $prg->getAssignmentsOf($usr3->getId()));
85  $this->assertCount(1, $prg->getAssignmentsOf($usr4->getId()));
86 
87  foreach ($prg->getAssignmentsOf($usr1->getId()) as $ass) {
88  if ($ass->getId() !== $assignment1->getId()) {
89  $assignment1_r = $ass;
90  }
91  if ($ass->getId() === $assignment1->getId()) {
92  $assignment1 = $ass;
93  }
94  }
95  $this->assertEquals($assignment1->getRestartedAssignmentId(), $assignment1_r->getId());
96  }
+ Here is the call graph for this function:

Field Documentation

◆ $assignment_repo

ilPrgRestartAssignmentsCronJobTest::$assignment_repo
protected

Definition at line 10 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $backupGlobals

ilPrgRestartAssignmentsCronJobTest::$backupGlobals = false
protected

Definition at line 8 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $instances

ilPrgRestartAssignmentsCronJobTest::$instances = []
staticprotected

Definition at line 12 of file ilPrgRestartAssignmentsCronJobTest.php.

◆ $users

ilPrgRestartAssignmentsCronJobTest::$users = []
staticprotected

Definition at line 13 of file ilPrgRestartAssignmentsCronJobTest.php.


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