Differences Between: [Versions 400 and 403] [Versions 401 and 403]
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 mod_lti\external; 18 19 use core_external\external_api; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 global $CFG; 24 25 require_once($CFG->dirroot . '/mod/lti/tests/mod_lti_testcase.php'); 26 27 /** 28 * PHPUnit tests for get_tool_types_and_proxies_count external function. 29 * 30 * @package mod_lti 31 * @author Andrew Madden <andrewmadden@catalyst-au.net> 32 * @copyright 2021 Catalyst IT 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class get_tool_types_and_proxies_count_test extends \mod_lti_testcase { 36 37 /** 38 * This method runs before every test. 39 */ 40 public function setUp(): void { 41 $this->resetAfterTest(); 42 $this->setAdminUser(); 43 } 44 45 /** 46 * Test get_tool_types_and_proxies_count returns the correct number. 47 */ 48 public function test_mod_lti_get_tool_types_and_proxies_count() { 49 for ($i = 0; $i < 10; $i++) { 50 $proxy = $this->generate_tool_proxy($i); 51 $this->generate_tool_type($i, $proxy->id); 52 } 53 54 $data = \mod_lti\external\get_tool_types_and_proxies_count::execute(0, false); 55 $data = external_api::clean_returnvalue(\mod_lti\external\get_tool_types_and_proxies_count::execute_returns(), $data); 56 57 $this->assertEquals(20, $data['count']); 58 } 59 60 /** 61 * Test get_tool_types_and_proxies_count returns the correct number. 62 */ 63 public function test_mod_lti_get_tool_types_and_proxies_count_with_no_tools_configured() { 64 $data = \mod_lti\external\get_tool_types_and_proxies_count::execute(0, false); 65 $data = external_api::clean_returnvalue(\mod_lti\external\get_tool_types_and_proxies_count::execute_returns(), $data); 66 67 $this->assertEquals(0, $data['count']); 68 } 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body