Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliusJensen02 committed Oct 29, 2024
1 parent 015e1e8 commit 187df9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/moodle/mod/homework/tests/save_homework_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public function test_save_homework_literature(): void {
$inputfield = 'Test Literature';
$startpage = 1;
$endpage = 10;
$homework = 1;

$result = \mod_homework\external\save_homework_literature::execute($inputfield, $startpage, $endpage);
$result = \mod_homework\external\save_homework_literature::execute($inputfield, $startpage, $endpage, $homework);

// Assert that the status is 'success'.
$this->assertEquals('success', $result['status']);
Expand All @@ -70,6 +71,7 @@ public function test_save_homework_literature(): void {
);
$this->assertEquals($startpage, $record->startpage);
$this->assertEquals($endpage, $record->endpage);
$this->assertEquals($homework, $record->homework);
}

/**
Expand All @@ -84,8 +86,9 @@ public function test_save_homework_link(): void {
// Call the external class method.
$inputfield = 'Test Link';
$link = 'https://www.test.com';
$homework = 1;

$result = \mod_homework\external\save_homework_link::execute($inputfield, $link);
$result = \mod_homework\external\save_homework_link::execute($inputfield, $link, $homework);

// Assert that the status is 'success'.
$this->assertEquals('success', $result['status']);
Expand All @@ -100,5 +103,6 @@ public function test_save_homework_link(): void {
MUST_EXIST
);
$this->assertEquals($link, $record->link);
$this->assertEquals($homework, $record->homework);
}
}

0 comments on commit 187df9b

Please sign in to comment.