-
Notifications
You must be signed in to change notification settings - Fork 159
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
6 changed files
with
83 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,13 @@ | |
* @copyright 2018 Dmitrii Metelkin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace customcertelement_daterange; | ||
|
||
use stdClass; | ||
use advanced_testcase; | ||
use fake_datarange_element; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
|
@@ -34,7 +41,7 @@ | |
* @copyright 2018 Dmitrii Metelkin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class customcertelement_daterange_element_test extends advanced_testcase { | ||
class element_test extends advanced_testcase { | ||
|
||
/** | ||
* Helper function to build element data. | ||
|
@@ -82,7 +89,7 @@ protected function build_datarange_data(array $dataranges, $fallbackstring = '') | |
* @param array $dataranges A list of dataranges. | ||
* @param string $fallbackstring Fall back strin | ||
* | ||
* @return \fake_datarange_element | ||
* @return fake_datarange_element | ||
*/ | ||
protected function get_datarange_element(array $dataranges, $fallbackstring = '') { | ||
$datarangedata = $this->build_datarange_data($dataranges, $fallbackstring); | ||
|
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 |
---|---|---|
|
@@ -23,6 +23,14 @@ | |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_customcert; | ||
|
||
use grade_item; | ||
use grade_grade; | ||
use context_module; | ||
use context_system; | ||
use advanced_testcase; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
|
@@ -35,7 +43,7 @@ | |
* @copyright 2017 Mark Nelson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class mod_customcert_element_helper_testcase extends advanced_testcase { | ||
class element_helper_test extends advanced_testcase { | ||
|
||
/** | ||
* Test set up. | ||
|
@@ -58,7 +66,7 @@ public function test_get_courseid_element_in_course_certificate() { | |
|
||
// Get the template to add elements to. | ||
$template = $DB->get_record('customcert_templates', array('contextid' => context_module::instance($customcert->cmid)->id)); | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to the template. | ||
$pageid = $template->add_page(); | ||
|
@@ -68,12 +76,12 @@ public function test_get_courseid_element_in_course_certificate() { | |
$element->name = 'Test element'; | ||
$element->element = 'testelement'; | ||
$element->pageid = $pageid; | ||
$element->sequence = \mod_customcert\element_helper::get_element_sequence($element->pageid); | ||
$element->sequence = element_helper::get_element_sequence($element->pageid); | ||
$element->timecreated = time(); | ||
$element->id = $DB->insert_record('customcert_elements', $element); | ||
|
||
// Confirm the correct course id is returned. | ||
$this->assertEquals($course->id, \mod_customcert\element_helper::get_courseid($element->id)); | ||
$this->assertEquals($course->id, element_helper::get_courseid($element->id)); | ||
} | ||
|
||
/** | ||
|
@@ -83,7 +91,7 @@ public function test_get_courseid_element_in_site_template() { | |
global $DB, $SITE; | ||
|
||
// Add a template to the site. | ||
$template = \mod_customcert\template::create('Site template', context_system::instance()->id); | ||
$template = template::create('Site template', context_system::instance()->id); | ||
|
||
// Add a page to the template. | ||
$pageid = $template->add_page(); | ||
|
@@ -93,12 +101,12 @@ public function test_get_courseid_element_in_site_template() { | |
$element->name = 'Test element'; | ||
$element->element = 'testelement'; | ||
$element->pageid = $pageid; | ||
$element->sequence = \mod_customcert\element_helper::get_element_sequence($element->pageid); | ||
$element->sequence = element_helper::get_element_sequence($element->pageid); | ||
$element->timecreated = time(); | ||
$element->id = $DB->insert_record('customcert_elements', $element); | ||
|
||
// Confirm the correct course id is returned. | ||
$this->assertEquals($SITE->id, \mod_customcert\element_helper::get_courseid($element->id)); | ||
$this->assertEquals($SITE->id, element_helper::get_courseid($element->id)); | ||
} | ||
|
||
/** | ||
|
@@ -115,7 +123,7 @@ public function test_get_context_element_in_course_certificate() { | |
|
||
// Get the template to add elements to. | ||
$template = $DB->get_record('customcert_templates', array('contextid' => context_module::instance($customcert->cmid)->id)); | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to the template. | ||
$pageid = $template->add_page(); | ||
|
@@ -125,13 +133,13 @@ public function test_get_context_element_in_course_certificate() { | |
$element->name = 'Test element'; | ||
$element->element = 'testelement'; | ||
$element->pageid = $pageid; | ||
$element->sequence = \mod_customcert\element_helper::get_element_sequence($element->pageid); | ||
$element->sequence = element_helper::get_element_sequence($element->pageid); | ||
$element->timecreated = time(); | ||
$element->id = $DB->insert_record('customcert_elements', $element); | ||
|
||
// Confirm the correct course module id is returned. | ||
$this->assertEquals(context_module::instance($customcert->cmid), | ||
\mod_customcert\element_helper::get_context($element->id)); | ||
element_helper::get_context($element->id)); | ||
} | ||
|
||
/** | ||
|
@@ -141,7 +149,7 @@ public function test_get_context_element_in_site_template() { | |
global $DB; | ||
|
||
// Add a template to the site. | ||
$template = \mod_customcert\template::create('Site template', context_system::instance()->id); | ||
$template = template::create('Site template', context_system::instance()->id); | ||
|
||
// Add a page to the template. | ||
$pageid = $template->add_page(); | ||
|
@@ -151,12 +159,12 @@ public function test_get_context_element_in_site_template() { | |
$element->name = 'Test element'; | ||
$element->element = 'testelement'; | ||
$element->pageid = $pageid; | ||
$element->sequence = \mod_customcert\element_helper::get_element_sequence($element->pageid); | ||
$element->sequence = element_helper::get_element_sequence($element->pageid); | ||
$element->timecreated = time(); | ||
$element->id = $DB->insert_record('customcert_elements', $element); | ||
|
||
// Confirm the correct course module id is returned. | ||
$this->assertEquals(context_system::instance(), \mod_customcert\element_helper::get_context($element->id)); | ||
$this->assertEquals(context_system::instance(), element_helper::get_context($element->id)); | ||
} | ||
|
||
/** | ||
|
@@ -190,7 +198,7 @@ public function test_get_grade_items() { | |
); | ||
|
||
// Confirm the function returns the correct number of grade items. | ||
$gradeitems = \mod_customcert\element_helper::get_grade_items($course); | ||
$gradeitems = element_helper::get_grade_items($course); | ||
$this->assertCount(6, $gradeitems); | ||
$this->assertArrayHasKey($assign1->cmid, $gradeitems); | ||
$this->assertArrayHasKey($assign2->cmid, $gradeitems); | ||
|
@@ -244,7 +252,7 @@ public function test_get_mod_grade_info() { | |
$grade->insert(); | ||
|
||
// Check that the user received the grade. | ||
$grade = \mod_customcert\element_helper::get_mod_grade_info( | ||
$grade = element_helper::get_mod_grade_info( | ||
$assign->cmid, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student1->id | ||
|
@@ -256,7 +264,7 @@ public function test_get_mod_grade_info() { | |
$this->assertEquals($time, $grade->get_dategraded()); | ||
|
||
// Check that the user we did not grade has no grade. | ||
$grade = \mod_customcert\element_helper::get_mod_grade_info( | ||
$grade = element_helper::get_mod_grade_info( | ||
$assign->cmid, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student2->id | ||
|
@@ -304,7 +312,7 @@ public function test_get_course_grade_info() { | |
$grade->insert(); | ||
|
||
// Check that the user received the grade. | ||
$grade = \mod_customcert\element_helper::get_course_grade_info( | ||
$grade = element_helper::get_course_grade_info( | ||
$course->id, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student1->id | ||
|
@@ -316,7 +324,7 @@ public function test_get_course_grade_info() { | |
$this->assertEquals($time, $grade->get_dategraded()); | ||
|
||
// Check that the user we did not grade has no grade. | ||
$grade = \mod_customcert\element_helper::get_course_grade_info( | ||
$grade = element_helper::get_course_grade_info( | ||
$course->id, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student2->id | ||
|
@@ -366,7 +374,7 @@ public function test_get_grade_item_info() { | |
$grade->insert(); | ||
|
||
// Check that the user received the grade. | ||
$grade = \mod_customcert\element_helper::get_grade_item_info( | ||
$grade = element_helper::get_grade_item_info( | ||
$gi->id, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student1->id | ||
|
@@ -378,7 +386,7 @@ public function test_get_grade_item_info() { | |
$this->assertEquals($time, $grade->get_dategraded()); | ||
|
||
// Check that the user we did not grade has no grade. | ||
$grade = \mod_customcert\element_helper::get_grade_item_info( | ||
$grade = element_helper::get_grade_item_info( | ||
$gi->id, | ||
GRADE_DISPLAY_TYPE_PERCENTAGE, | ||
$student2->id | ||
|
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 |
---|---|---|
|
@@ -23,6 +23,13 @@ | |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_customcert; | ||
|
||
use stdClass; | ||
use context_course; | ||
use advanced_testcase; | ||
use mod_customcert\task\email_certificate_task; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
|
@@ -33,7 +40,7 @@ | |
* @copyright 2017 Mark Nelson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class mod_customcert_task_email_certificate_task_testcase extends advanced_testcase { | ||
class email_certificate_task_test extends advanced_testcase { | ||
|
||
/** | ||
* Test set up. | ||
|
@@ -60,7 +67,7 @@ public function test_email_certificates_no_elements() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -96,7 +103,7 @@ public function test_email_certificates_no_cap() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -109,7 +116,7 @@ public function test_email_certificates_no_cap() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -148,7 +155,7 @@ public function test_email_certificates_students() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -167,7 +174,7 @@ public function test_email_certificates_students() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -192,7 +199,7 @@ public function test_email_certificates_students() { | |
|
||
// Now, run the task again and ensure we did not issue any more certificates. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -233,7 +240,7 @@ public function test_email_certificates_teachers() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -246,7 +253,7 @@ public function test_email_certificates_teachers() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -286,7 +293,7 @@ public function test_email_certificates_others() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -299,7 +306,7 @@ public function test_email_certificates_others() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -337,7 +344,7 @@ public function test_email_certificates_students_not_visible() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -353,7 +360,7 @@ public function test_email_certificates_students_not_visible() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
@@ -392,7 +399,7 @@ public function test_email_certificates_students_havent_met_required_time() { | |
$template->id = $customcert->templateid; | ||
$template->name = 'A template'; | ||
$template->contextid = context_course::instance($course->id)->id; | ||
$template = new \mod_customcert\template($template); | ||
$template = new template($template); | ||
|
||
// Add a page to this template. | ||
$pageid = $template->add_page(); | ||
|
@@ -405,7 +412,7 @@ public function test_email_certificates_students_havent_met_required_time() { | |
|
||
// Run the task. | ||
$sink = $this->redirectEmails(); | ||
$task = new \mod_customcert\task\email_certificate_task(); | ||
$task = new email_certificate_task(); | ||
$task->execute(); | ||
$emails = $sink->get_messages(); | ||
|
||
|
Oops, something went wrong.