Skip to content

Commit

Permalink
Fixed a broken unit test, updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
ADLMeganBohland committed Sep 18, 2024
1 parent 587323b commit 8bf2a4e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion cmi5PHP/tests/session_helpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 8bf2a4e

Please sign in to comment.