diff --git a/enrol/lti/classes/helper.php b/enrol/lti/classes/helper.php index a101b0d2437..3d3eede0fbc 100644 --- a/enrol/lti/classes/helper.php +++ b/enrol/lti/classes/helper.php @@ -450,58 +450,26 @@ class helper { /** * Returns the url to the cartridge representing the tool. * - * If you have slash arguments enabled, this will be a nice url ending in cartridge.xml. - * If not it will be a php page with some parameters passed. - * * @param \stdClass $tool The lti tool * @return string The url to the cartridge representing the tool * @since Moodle 3.2 */ public static function get_cartridge_url($tool) { - global $CFG; - $url = null; - $id = $tool->id; $token = self::generate_cartridge_token($tool->id); - if ($CFG->slasharguments) { - $url = new \moodle_url('/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml'); - } else { - $url = new \moodle_url('/enrol/lti/cartridge.php', - array( - 'id' => $id, - 'token' => $token - ) - ); - } - return $url; + return new \moodle_url('/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml'); } /** * Returns the url to the tool proxy registration url. * - * If you have slash arguments enabled, this will be a nice url ending in cartridge.xml. - * If not it will be a php page with some parameters passed. - * * @param \stdClass $tool The lti tool * @return string The url to the cartridge representing the tool */ public static function get_proxy_url($tool) { - global $CFG; - $url = null; - $id = $tool->id; $token = self::generate_proxy_token($tool->id); - if ($CFG->slasharguments) { - $url = new \moodle_url('/enrol/lti/proxy.php/' . $id . '/' . $token . '/'); - } else { - $url = new \moodle_url('/enrol/lti/proxy.php', - array( - 'id' => $id, - 'token' => $token - ) - ); - } - return $url; + return new \moodle_url('/enrol/lti/proxy.php/' . $id . '/' . $token . '/'); } /** diff --git a/enrol/lti/tests/helper_test.php b/enrol/lti/tests/helper_test.php index 367feec0904..3f0f1a9158f 100644 --- a/enrol/lti/tests/helper_test.php +++ b/enrol/lti/tests/helper_test.php @@ -22,6 +22,8 @@ namespace enrol_lti; * @package enrol_lti * @copyright 2016 Mark Nelson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * + * @covers \enrol_lti\helper */ class helper_test extends \advanced_testcase { @@ -260,12 +262,6 @@ class helper_test extends \advanced_testcase { * Test getting the cartridge url of a tool. */ public function test_get_cartridge_url(): void { - global $CFG; - - $slasharguments = $CFG->slasharguments; - - $CFG->slasharguments = false; - $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -273,29 +269,16 @@ class helper_test extends \advanced_testcase { $id = $tool1->id; $token = \enrol_lti\helper::generate_cartridge_token($id); - $launchurl = \enrol_lti\helper::get_cartridge_url($tool1); - $this->assertEquals('https://www.example.com/moodle/enrol/lti/cartridge.php?id=' . $id . '&token=' . $token, - $launchurl->out()); - - $CFG->slasharguments = true; - + /** @var \moodle_url $launchurl */ $launchurl = \enrol_lti\helper::get_cartridge_url($tool1); $this->assertEquals('https://www.example.com/moodle/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml', $launchurl->out()); - - $CFG->slasharguments = $slasharguments; } /** * Test getting the cartridge url of a tool. */ public function test_get_proxy_url(): void { - global $CFG; - - $slasharguments = $CFG->slasharguments; - - $CFG->slasharguments = false; - $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -303,17 +286,10 @@ class helper_test extends \advanced_testcase { $id = $tool1->id; $token = \enrol_lti\helper::generate_proxy_token($id); - $launchurl = \enrol_lti\helper::get_proxy_url($tool1); - $this->assertEquals('https://www.example.com/moodle/enrol/lti/proxy.php?id=' . $id . '&token=' . $token, - $launchurl->out()); - - $CFG->slasharguments = true; - + /** @var \moodle_url $launchurl */ $launchurl = \enrol_lti\helper::get_proxy_url($tool1); $this->assertEquals('https://www.example.com/moodle/enrol/lti/proxy.php/' . $id . '/' . $token . '/', $launchurl->out()); - - $CFG->slasharguments = $slasharguments; } /**