Differences Between: [Versions 311 and 402] [Versions 311 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 /** 18 * External function test for prepare_entry. 19 * 20 * @package mod_glossary 21 * @category external 22 * @since Moodle 3.10 23 * @copyright 2020 Juan Leyva <juan@moodle.com> 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 namespace mod_glossary\external; 28 29 defined('MOODLE_INTERNAL') || die(); 30 31 global $CFG; 32 require_once($CFG->dirroot . '/webservice/tests/helpers.php'); 33 34 use external_api; 35 use externallib_advanced_testcase; 36 use mod_glossary_external; 37 use context_module; 38 use context_user; 39 use external_util; 40 41 /** 42 * External function test for prepare_entry. 43 * 44 * @package mod_glossary 45 * @copyright 2020 Juan Leyva <juan@moodle.com> 46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 47 */ 48 class prepare_entry_testcase extends externallib_advanced_testcase { 49 50 /** 51 * test_prepare_entry 52 */ 53 public function test_prepare_entry() { 54 global $USER; 55 $this->resetAfterTest(true); 56 57 $course = $this->getDataGenerator()->create_course(); 58 $glossary = $this->getDataGenerator()->create_module('glossary', ['course' => $course->id]); 59 $gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary'); 60 61 $this->setAdminUser(); 62 $aliases = ['alias1', 'alias2']; 63 $entry = $gg->create_content( 64 $glossary, 65 ['approved' => 1, 'userid' => $USER->id], 66 $aliases 67 ); 68 69 $cat1 = $gg->create_category($glossary, [], [$entry]); 70 $gg->create_category($glossary); 71 72 $return = prepare_entry::execute($entry->id); 73 $return = external_api::clean_returnvalue(prepare_entry::execute_returns(), $return); 74 75 $this->assertNotEmpty($return['inlineattachmentsid']); 76 $this->assertNotEmpty($return['attachmentsid']); 77 $this->assertEquals($aliases, $return['aliases']); 78 $this->assertEquals([$cat1->id], $return['categories']); 79 $this->assertCount(2, $return['areas']); 80 $this->assertNotEmpty($return['areas'][0]['options']); 81 $this->assertNotEmpty($return['areas'][1]['options']); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body