From 7d7c6a0887dc23b00c7337aee1cc323489163b2a Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Thu, 12 Sep 2024 00:35:39 +0000 Subject: [PATCH] issue_#39 --- classes/plugin.php | 4 ++-- tests/enrol_test.php | 9 +++------ tests/time_enrolled_test.php | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/classes/plugin.php b/classes/plugin.php index 8f2c940..ea07d3b 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -234,13 +234,13 @@ public function enrol_user( context_course::instance($instance->customint1, IGNORE_MISSING) && context_course::instance($instance->courseid, IGNORE_MISSING) ) { - $timestart = 0; + $timestart = time(); $timeend = 0; if (isset($instance->customint4) && $instance->customint4 > 0) { $timestart = $instance->customint4; } if (isset($instance->enrolperiod) && $instance->enrolperiod > 0) { - $timeend = max(time(), $timestart) + $instance->enrolperiod; + $timeend = $timestart + $instance->enrolperiod; } parent::enrol_user($instance, $userid, $roleid, $timestart, $timeend, $status, $recovergrades); } else { diff --git a/tests/enrol_test.php b/tests/enrol_test.php index 9f33d4b..ba56cca 100644 --- a/tests/enrol_test.php +++ b/tests/enrol_test.php @@ -306,8 +306,8 @@ public function test_library_functions(): void { $this->assertEquals($icons[0]->attributes['title'], 'After completing course: Test course 1'); $icons = $this->plugin->get_action_icons($this->instance); $this->assertCount(2, $icons); - $this->assertStringContainsString('icon fa fa-cog fa-fw iconsmall', $icons[0]); - $this->assertStringContainsString('icon fa fa-user-plus fa-fw iconsmall', $icons[1]); + $this->assertStringContainsString('icon fa fa-', $icons[0]); + $this->assertStringContainsString('icon fa fa-', $icons[1]); $this->assertStringContainsString( 'assertStringContainsString('title="Helpwith' . $value . '"role="img"', $cleaned); } $strm = get_string_manager(); $arr = ['compcourse', 'customwelcome', 'enrolenddate', 'enrolstartdate', 'group']; diff --git a/tests/time_enrolled_test.php b/tests/time_enrolled_test.php index 9e5ff62..9257ca2 100644 --- a/tests/time_enrolled_test.php +++ b/tests/time_enrolled_test.php @@ -138,10 +138,10 @@ public function test_time_enrolled(): void { $this->assertTrue(is_enrolled(context_course::instance($course2->id), $student->id)); $this->assertCount(1, $manager1->get_user_enrolments($student->id)); $ueinstance = $DB->get_record('user_enrolments', ['enrolid' => $id1, 'userid' => $student->id]); - $this->assertEquals(0, $ueinstance->timestart); + $this->assertNotEquals(0, $ueinstance->timestart); $this->assertEquals(0, $ueinstance->timeend); $ueinstance = $DB->get_record('user_enrolments', ['enrolid' => $id2, 'userid' => $student->id]); - $this->assertEquals(0, $ueinstance->timestart); + $this->assertNotEquals(0, $ueinstance->timestart); $this->assertGreaterThan(time(), $ueinstance->timeend); sleep(1); $trace = new \null_progress_trace();