From bcccbd1f8ec4d119e5d2d3ce01943163a64b1150 Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 26 Nov 2024 12:08:09 +0000 Subject: [PATCH] Fixing unit tests --- tests/lib_test.php | 51 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/tests/lib_test.php b/tests/lib_test.php index b9a8956..ecb4e65 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -139,40 +139,6 @@ public function setUp(): void { $this->eulaurl = get_config('plagiarism_turnitinsim', 'turnitin_eula_url', self::TURNITINSIM_API_URL); } - /** - * Save Form elements - */ - public function test_save_form_elements() { - global $DB; - - $this->resetAfterTest(); - - // Create data object for new assignment. - $data = new stdClass(); - $data->modulename = 'assign'; - $data->coursemodule = 1; - $data->turnitinenabled = 1; - - $plugin = new plagiarism_plugin_turnitinsim(); - $plugin->save_form_elements($data); - - // Check settings are not saved. - $settings = $DB->get_record('plagiarism_turnitinsim_mod', array('cm' => $data->coursemodule)); - - $this->assertEmpty($settings); - - // Set plugin as enabled in config for this module type. - plagiarism_plugin_turnitinsim::enable_plugin(1); - set_config('turnitinmodenabledassign', 1, 'plagiarism_turnitinsim'); - - $plugin->save_form_elements($data); - - // Check settings are saved. - $settings = $DB->get_record('plagiarism_turnitinsim_mod', array('cm' => $data->coursemodule)); - - $this->assertEquals(1, $settings->turnitinenabled); - } - /** * Test that get_links returns an empty div if there is no submission. */ @@ -421,9 +387,10 @@ public function test_is_plugin_active_not_enabled_for_mod() { $data->coursemodule = $this->cm->id; $data->turnitinenabled = 0; - $plugin = new plagiarism_plugin_turnitinsim(); - $plugin->save_form_elements($data); + $form = new plagiarism_turnitinsim_settings(); + $form->save_module_settings($data); + $plugin = new plagiarism_plugin_turnitinsim(); $this->assertFalse($plugin->is_plugin_active($this->cm)); } @@ -490,8 +457,8 @@ public function test_print_disclosure_display_latest() { $data->modulename = 'assign'; $data->coursemodule = $this->cm->id; $data->turnitinenabled = 1; - $plugin = new plagiarism_plugin_turnitinsim(); - $plugin->save_form_elements($data); + $form = new plagiarism_turnitinsim_settings(); + $form->save_module_settings($data); // Log student in. $this->setUser($this->student1); @@ -526,8 +493,8 @@ public function test_print_disclosure_not_display_latest() { $data->modulename = 'assign'; $data->coursemodule = $this->cm->id; $data->turnitinenabled = 1; - $plugin = new plagiarism_plugin_turnitinsim(); - $plugin->save_form_elements($data); + $form = new plagiarism_turnitinsim_settings(); + $form->save_module_settings($data); // Accept EULA for student. $data = $DB->get_record('plagiarism_turnitinsim_users', ['userid' => $this->student1->id]); @@ -563,8 +530,8 @@ public function test_print_disclosure_eula_not_displayed_if_not_required() { $data->modulename = 'assign'; $data->coursemodule = $this->cm->id; $data->turnitinenabled = 1; - $plugin = new plagiarism_plugin_turnitinsim(); - $plugin->save_form_elements($data); + $form = new plagiarism_turnitinsim_settings(); + $form->save_module_settings($data); // Log student in. $this->setUser($this->student1);