From 8bf2a4ea18a6a13c5611d3c9877b1bede91491e3 Mon Sep 17 00:00:00 2001 From: ADLMeganBohland Date: Wed, 18 Sep 2024 17:51:51 -0400 Subject: [PATCH] Fixed a broken unit test, updated version --- cmi5PHP/tests/session_helpersTest.php | 21 ++++++++++++++++++++- version.php | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cmi5PHP/tests/session_helpersTest.php b/cmi5PHP/tests/session_helpersTest.php index 4fa601d..bcdf19a 100644 --- a/cmi5PHP/tests/session_helpersTest.php +++ b/cmi5PHP/tests/session_helpersTest.php @@ -185,17 +185,36 @@ public function testcmi5launch_create_session() { global $DB, $cmi5launch, $cmi5launchid, $sessionids, $USER; + // Fake values. $sessionid = '100'; $launchurl = "http://test.com"; $launchmethod = "ownWindow"; $tenantname = $USER->username; + // We need to make a fake session for the mocked function to return. + // Make a new record to save. + $mockedsession = new \stdClass(); + // Because of many nested properties, needs to be done manually. + $mockedsession->sessionid = $sessionid; + $mockedsession->launchurl = $launchurl; + $mockedsession->tenantname = $USER->username; + $mockedsession->launchmethod = $launchmethod; + // I think here is where we eed to implement : moodlecourseid + $mockedsession->moodlecourseid = $cmi5launch->id; + // And userid! + $mockedsession->userid = $USER->id; + // New session_helpers from mod_cmi5launch $helpers = new \mod_cmi5launch\local\session_helpers(); + // Create a mock since we need to mock the update session function. + $mock = $this->getMockBuilder($helpers::class) + ->onlyMethods(['cmi5launch_update_sessions']) // Specify only the allowed method + ->getMock(); + // Result of the function. - $resultid = $helpers->cmi5launch_create_session($sessionid, $launchurl, $launchmethod); + $resultid = $mock->cmi5launch_create_session($sessionid, $launchurl, $launchmethod); // Returns a new id. $this->assertIsInt($resultid, "Result should be an int."); diff --git a/version.php b/version.php index 03d7656..51b469a 100755 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024072517; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2024081516; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2015111000; // Requires Moodle 3.0 version. $plugin->cron = 0; // Period for cron to check this module (secs).