See Release Notes
Long Term Support Release
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace enrol_lti\local\ltiadvantage\repository; 18 19 defined('MOODLE_INTERNAL') || die(); 20 21 require_once (__DIR__ . '/../lti_advantage_testcase.php'); 22 23 /** 24 * Tests for legacy_consumer_repository. 25 * 26 * @package enrol_lti 27 * @copyright 2021 Jake Dallimore <jrhdallimore@gmail.com> 28 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 29 * @coversDefaultClass \enrol_lti\local\ltiadvantage\repository\legacy_consumer_repository 30 */ 31 class legacy_consumer_repository_test extends \lti_advantage_testcase { 32 /** 33 * Test the get_consumer_secrets repository method. 34 * 35 * @covers ::get_consumer_secrets 36 */ 37 public function test_get_consumer_secrets() { 38 $this->resetAfterTest(); 39 // Set up legacy consumer information. 40 $course = $this->getDataGenerator()->create_course(); 41 42 // Note below that 2 tools with the same secret have been used (three tools total) 43 // but we expect only the distinct secrets to be returned. 44 $legacydata = [ 45 'users' => [ 46 ['user_id' => '123-abc'], 47 ], 48 'consumer_key' => 'CONSUMER_1', 49 'tools' => [ 50 ['secret' => 'toolsecret1'], 51 ['secret' => 'toolsecret1'], 52 ['secret' => 'toolsecret2'], 53 ] 54 ]; 55 [$tools, $consumer, $users] = $this->setup_legacy_data($course, $legacydata); 56 57 $legacyconsumerrepo = new legacy_consumer_repository(); 58 59 // Find the tool secrets associated with 'CONSUMER_1'. 60 $consumersecrets = $legacyconsumerrepo->get_consumer_secrets('CONSUMER_1'); 61 $this->assertCount(2, $consumersecrets); 62 foreach ($consumersecrets as $consumersecret) { 63 $this->assertContains($consumersecret, ['toolsecret1', 'toolsecret2']); 64 } 65 66 // Verify an empty array is returned for a non-existent consumer. 67 $this->assertEmpty($legacyconsumerrepo->get_consumer_secrets('CONSUMER_2')); 68 } 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body