Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing unit tests #186

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 9 additions & 42 deletions tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down