MDL-79675 enrol_lti: fix mocks depending on previously untyped props

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.
This commit is contained in:
Jake Dallimore 2024-02-22 16:58:46 +08:00
parent 4fda419e88
commit c043c180de
No known key found for this signature in database

View File

@ -138,7 +138,7 @@ abstract class lti_advantage_testcase extends \advanced_testcase {
?array $customparams = null, $aud = '123'): LtiMessageLaunch {
$mocklaunch = $this->getMockBuilder(LtiMessageLaunch::class)
->onlyMethods(['getLaunchData'])
->onlyMethods(['getLaunchData', 'getLaunchId'])
->disableOriginalConstructor()
->getMock();
$mocklaunch->expects($this->any())
@ -246,6 +246,12 @@ abstract class lti_advantage_testcase extends \advanced_testcase {
}
));
$mocklaunch->expects($this->any())
->method('getLaunchId')
->will($this->returnCallback(function() {
return uniqid('lti1p3_launch_', true);
}));
return $mocklaunch;
}