ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPrgInvalidateExpiredProgressesCronJobTest Class Reference

@group needsInstalledILIAS More...

+ Inheritance diagram for ilPrgInvalidateExpiredProgressesCronJobTest:
+ Collaboration diagram for ilPrgInvalidateExpiredProgressesCronJobTest:

Public Member Functions

 test_init ()
 
 test_run ($job)
 @depends test_init More...
 

Static Public Member Functions

static setUpBeforeClass ()
 
static tearDownAfterClass ()
 

Protected Member Functions

 newUser ()
 
 newPrg ()
 

Protected Attributes

 $backupGlobals = false
 

Static Protected Attributes

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

Detailed Description

@group needsInstalledILIAS

Definition at line 6 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

Member Function Documentation

◆ newPrg()

ilPrgInvalidateExpiredProgressesCronJobTest::newPrg ( )
protected

Definition at line 133 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

134 {
136 self::$instances[] = $prg;
137 return $prg;
138 }
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.

References ilObjStudyProgramme\createInstance().

Referenced by test_run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newUser()

ilPrgInvalidateExpiredProgressesCronJobTest::newUser ( )
protected

Definition at line 125 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

126 {
127 $user = new ilObjUser();
128 $user->create();
129 self::$users[] = $user;
130 return $user;
131 }

Referenced by test_run().

+ Here is the caller graph for this function:

◆ setUpBeforeClass()

static ilPrgInvalidateExpiredProgressesCronJobTest::setUpBeforeClass ( )
static

Definition at line 13 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

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

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

◆ tearDownAfterClass()

static ilPrgInvalidateExpiredProgressesCronJobTest::tearDownAfterClass ( )
static

Definition at line 111 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

111 : void
112 {
113 foreach (self::$instances as $instance) {
114 try {
115 $instance->delete();
116 } catch (Exception $e) {
117 }
118 }
119 foreach (self::$users as $user) {
120 $user->delete();
121 }
122 }

References Vendor\Package\$e.

◆ test_init()

ilPrgInvalidateExpiredProgressesCronJobTest::test_init ( )

Definition at line 27 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

28 {
30 $this->assertInstanceOf(ilCronJob::class, $job);
31 return $job;
32 }
This ivalidates a successful progress if validityOfQualification is reached.

◆ test_run()

ilPrgInvalidateExpiredProgressesCronJobTest::test_run (   $job)

@depends test_init

Definition at line 37 of file ilPrgInvalidateExpiredProgressesCronJobTest.php.

38 {
39 $usr1 = $this->newUser();
40 $usr2 = $this->newUser();
41 $usr3 = $this->newUser();
42 $usr4 = $this->newUser();
43
44 $prg1 = $this->newPrg();
45 $prg2 = $this->newPrg();
46
47 $prg1->putInTree(ROOT_FOLDER_ID);
48 $prg1->addNode($prg2);
49
50 $val_date_ref = new DateTime();
51 $val_date_ref->sub(new DateInterval('P1D'));
52 $prg1->setValidityOfQualificationDate($val_date_ref);
54 $prg1->update();
55
57
58 $assignment1 = $prg1->assignUser($usr1->getId(), 6);
59 $assignment2 = $prg1->assignUser($usr2->getId(), 6);
60 $assignment3 = $prg1->assignUser($usr3->getId(), 6);
61 $assignment4 = $prg1->assignUser($usr4->getId(), 6);
62
63
64 $progress = $prg2->getProgressForAssignment($assignment1->getId());
65 $progress->markAccredited(6);
66
67 $this->assertTrue($prg1->getProgressForAssignment($assignment1->getId())->isSuccessful());
68
69 $progress = $prg1->getProgressForAssignment($assignment2->getId());
70 $progress->markAccredited(6);
71
72 $this->assertTrue($prg1->getProgressForAssignment($assignment2->getId())->isSuccessful());
73
74 $prg1->setValidityOfQualificationDate(null);
75 $prg1->update();
76
77 $progress = $prg2->getProgressForAssignment($assignment3->getId());
78 $progress->markAccredited(6);
79
80 $progress = $prg1->getProgressForAssignment($assignment4->getId());
81 $progress->markAccredited(6);
82
83
84 $job->run();
85 $prgrs = $prg1->getProgressForAssignment($assignment1->getId());
86 $this->assertEquals(
88 $prgrs->getStatus()
89 );
90 $this->assertTrue($prgrs->isInvalidated());
91 $prgrs = $prg1->getProgressForAssignment($assignment2->getId());
92 $this->assertEquals(
94 $prgrs->getStatus()
95 );
96 $this->assertTrue($prgrs->isInvalidated());
97 $prgrs = $prg1->getProgressForAssignment($assignment3->getId());
98 $this->assertEquals(
100 $prgrs->getStatus()
101 );
102 $this->assertFalse($prgrs->isInvalidated());
103 $prgrs = $prg1->getProgressForAssignment($assignment4->getId());
104 $this->assertEquals(
106 $prgrs->getStatus()
107 );
108 $this->assertFalse($prgrs->isInvalidated());
109 }
const ROOT_FOLDER_ID
Definition: constants.php:30

References newPrg(), newUser(), ROOT_FOLDER_ID, ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeSettings\STATUS_ACTIVE, and ilStudyProgrammeProgress\STATUS_COMPLETED.

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilPrgInvalidateExpiredProgressesCronJobTest::$backupGlobals = false
protected

◆ $instances

ilPrgInvalidateExpiredProgressesCronJobTest::$instances = []
staticprotected

◆ $users

ilPrgInvalidateExpiredProgressesCronJobTest::$users = []
staticprotected

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