-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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']; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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; | ||
} | ||
}; | ||
} | ||
} |