diff --git a/lang/en/enrol_coursecompleted.php b/lang/en/enrol_coursecompleted.php
index 535d790..d577919 100644
--- a/lang/en/enrol_coursecompleted.php
+++ b/lang/en/enrol_coursecompleted.php
@@ -25,15 +25,15 @@
$string['aftercourse'] = 'After completing course: {$a}';
$string['cachedef_compcourses'] = 'Enrolment on course completion cache';
-$string['coursecompleted:config'] = 'Configure enrol coursecompletion instances';
-$string['coursecompleted:manage'] = 'Manage enrolled users';
-$string['coursecompleted:enrolpast'] = 'Enrol users who completed courses in the past';
-$string['coursecompleted:unenrol'] = 'Unenrol users from course';
-$string['coursecompleted:unenrolself'] = 'Unenrol self from the course';
$string['compcourse'] = 'Completed course';
$string['compcourse_help'] = 'Which course have to be completed.';
$string['confirmbulkdeleteenrolment'] = 'Are you sure you want to delete these user enrolments?';
$string['confirmbulkediteenrolment'] = 'Are you sure you want to change these user enrolments?';
+$string['coursecompleted:config'] = 'Configure enrol coursecompletion instances';
+$string['coursecompleted:enrolpast'] = 'Enrol users who completed courses in the past';
+$string['coursecompleted:manage'] = 'Manage enrolled users';
+$string['coursecompleted:unenrol'] = 'Unenrol users from course';
+$string['coursecompleted:unenrolself'] = 'Unenrol self from the course';
$string['customwelcome'] = 'Custom welcome message';
$string['customwelcome_help'] = 'A custom welcome message may be added as plain text or Moodle-auto format, including HTML tags and multi-lang tags.
@@ -63,9 +63,9 @@
$string['status_link'] = 'enrol/coursecompleted';
$string['svglearnpath'] = 'Display learning path';
$string['svglearnpath_help'] = 'Display (possible) learning path using svg icons.';
+$string['unenrolusers'] = 'Unenrol users';
$string['uponcompleting'] = 'Upon completing course {$a}';
$string['usersenrolled'] = '{$a} Users enrolled';
-$string['unenrolusers'] = 'Unenrol users';
$string['welcome'] = 'Send course welcome message';
$string['welcome_help'] = 'When a user is enrolled in a course by completing another course, a welcome message email may be sent.';
$string['welcometocourse'] = 'Welcome to {$a->coursename}!
diff --git a/phpunit.xml b/phpunit.xml
index 27a4bf4..8ca69c0 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -46,6 +46,9 @@
renderer.php
rsslib.php
+
+ classes/form
+
diff --git a/tests/coverage.php b/tests/coverage.php
index d7e3061..e28e967 100644
--- a/tests/coverage.php
+++ b/tests/coverage.php
@@ -25,7 +25,19 @@
defined('MOODLE_INTERNAL') || die();
+/**
+ * Unit tests for the coursecompleted enrolment.
+ *
+ * @package enrol_coursecompleted
+ * @copyright 2017 eWallah (www.eWallah.net)
+ * @author Renaat Debleu
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
return new class extends phpunit_coverage_info {
/** @var array The list of folders relative to the plugin root to include in coverage generation. */
protected $includelistfolders = ['classes'];
+ /** @var array The list of folders relative to the plugin root to exclude in coverage generation. */
+ protected $excludelistfolders = ['classes/form'];
+ /** @var array The list of files relative to the plugin root to exclude in coverage generation. */
+ protected $excludelistfiles = ['lib.php'];
};
diff --git a/tests/enrol_test.php b/tests/enrol_test.php
index 9b5e8ad..303ebf5 100644
--- a/tests/enrol_test.php
+++ b/tests/enrol_test.php
@@ -28,7 +28,6 @@
defined('MOODLE_INTERNAL') || die();
global $CFG;
-require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/enrol/locallib.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
@@ -367,7 +366,7 @@ public function test_form(): void {
$page->set_pagelayout('standard');
$page->set_pagetype('course-view');
$page->set_url('/enrol/coursecompleted/manage.php?enrolid=' . $this->instance->id);
- $form = new temp_coursecompleted_form();
+ $form = $this->tempform();
$mform = $form->getform();
$this->plugin->edit_instance_form($this->instance, $mform, $context);
$this->assertStringContainsString('Required field', $mform->getReqHTML());
@@ -505,31 +504,34 @@ public function test_deletedcourse(): void {
$observer = new \enrol_coursecompleted_observer();
$observer->coursedeleted($event);
}
-}
-/**
- * Form object to be used in test case.
- *
- * @package enrol_coursecompleted
- * @copyright 2017 eWallah (www.eWallah.net)
- * @author Renaat Debleu
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class temp_coursecompleted_form extends \moodleform {
/**
- * Form definition.
- */
- public function definition() {
- // No definition required.
- }
- /**
- * Returns form reference
- * @return MoodleQuickForm
+ * Test form.
+ * @covers \enrol_coursecompleted_plugin
+ * @return \moodleform
*/
- public function getform() {
- $mform = $this->_form;
- // Set submitted flag, to simulate submission.
- $mform->_flagSubmitted = true;
- return $mform;
+ public function tempform() {
+ global $CFG;
+ require_once($CFG->libdir . '/formslib.php');
+
+ // Test form.
+ return new class tempform extends \moodleform {
+ /**
+ * Form definition.
+ */
+ public function definition() {
+ // No definition required.
+ }
+ /**
+ * Returns form reference
+ * @return MoodleQuickForm
+ */
+ public function getform() {
+ $mform = $this->_form;
+ // Set submitted flag, to simulate submission.
+ $mform->_flagSubmitted = true;
+ return $mform;
+ }
+ };
}
}