Merge branch 'MDL-82717-404' of https://github.com/liamgm/moodle into MOODLE_404_STABLE

This commit is contained in:
Jun Pataleta 2024-09-03 10:29:25 +08:00
commit 2558c6a9b9
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
2 changed files with 18 additions and 1 deletions

View File

@ -108,7 +108,7 @@ class nrps_info {
* @return \moodle_url the service URL.
*/
public function get_context_memberships_url(): \moodle_url {
return $this->contextmembershipsurl;
return clone $this->contextmembershipsurl;
}
/**

View File

@ -98,4 +98,21 @@ class nrps_info_test extends \advanced_testcase {
]
];
}
/**
* Verify that the contextmembershipurl property can be gotten and is immutable.
*
* @covers ::get_context_memberships_url
*/
public function test_get_context_memberships_url(): void {
$nrpsendpoint = 'https://lms.example.com/45/memberships';
$nrpsinfo = nrps_info::create(new \moodle_url($nrpsendpoint));
$membershipsurlcopy = $nrpsinfo->get_context_memberships_url();
$this->assertEquals($nrpsendpoint, $membershipsurlcopy->out(false));
$rlid = '01234567-1234-5678-90ab-123456789abc';
$membershipsurlcopy->param('rlid', $rlid);
$this->assertEquals($nrpsendpoint . '?rlid=' . $rlid, $membershipsurlcopy->out(false));
$this->assertEquals($nrpsendpoint, $nrpsinfo->get_context_memberships_url()->out(false));
}
}