Skip to content

Commit

Permalink
MDL-79675 enrol_lti: fix mocks depending on previously untyped props
Browse files Browse the repository at this point in the history
When $launch_id wasn't typed, it was ok to call the getter, but now
that it is, php throws an error. Replaced with stub method.
  • Loading branch information
snake committed Mar 6, 2024
1 parent 4fda419 commit c043c18
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function get_mock_launch(\stdClass $resource, array $mockuser,
?array $customparams = null, $aud = '123'): LtiMessageLaunch {

$mocklaunch = $this->getMockBuilder(LtiMessageLaunch::class)
->onlyMethods(['getLaunchData'])
->onlyMethods(['getLaunchData', 'getLaunchId'])
->disableOriginalConstructor()
->getMock();
$mocklaunch->expects($this->any())
Expand Down Expand Up @@ -246,6 +246,12 @@ function()
}
));

$mocklaunch->expects($this->any())
->method('getLaunchId')
->will($this->returnCallback(function() {
return uniqid('lti1p3_launch_', true);
}));

return $mocklaunch;
}

Expand Down

0 comments on commit c043c18

Please sign in to comment.