From 187df9b9e5195f27a0e9626cbfbdaab5b2b5afbb Mon Sep 17 00:00:00 2001 From: JuliusJensen02 <113088719+JuliusJensen02@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:03:11 +0100 Subject: [PATCH] Added tests --- server/moodle/mod/homework/tests/save_homework_test.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/moodle/mod/homework/tests/save_homework_test.php b/server/moodle/mod/homework/tests/save_homework_test.php index 521c36e83..d7ca132e8 100644 --- a/server/moodle/mod/homework/tests/save_homework_test.php +++ b/server/moodle/mod/homework/tests/save_homework_test.php @@ -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']); @@ -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); } /** @@ -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']); @@ -100,5 +103,6 @@ public function test_save_homework_link(): void { MUST_EXIST ); $this->assertEquals($link, $record->link); + $this->assertEquals($homework, $record->homework); } }