[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 * LTI upgrade script. 19 * 20 * @package mod_lti 21 * @copyright 2014 Vital Source Technologies http://vitalsource.com 22 * @author Stephen Vickers 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 global $CFG; 30 require_once($CFG->dirroot . '/mod/lti/locallib.php'); 31 require_once($CFG->dirroot . '/mod/lti/db/upgradelib.php'); 32 33 34 /** 35 * Unit tests for mod_lti upgrades. 36 * 37 * @package mod_lti 38 * @since Moodle 2.8 39 * @copyright 2014 Vital Source Technologies http://vitalsource.com 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class mod_lti_upgradelib_testcase extends advanced_testcase { 43 44 /** 45 * Test conversion of semicolon separated custom parameters. 46 */ 47 public function test_custom_parameter() { 48 global $DB, $SITE, $USER; 49 50 $custom1 = 'a=one;b=two;three=3'; 51 $custom2 = "a=one\nb=two\nthree=3"; 52 53 $this->resetAfterTest(true); 54 55 $ltigenerator = $this->getDataGenerator()->get_plugin_generator('mod_lti'); 56 57 // Create 2 tools with custom parameters. 58 $toolid1 = $DB->insert_record('lti_types', array('course' => $SITE->id, 'baseurl' => '', 'createdby' => $USER->id, 59 'timecreated' => time(), 'timemodified' => time())); 60 $configid1 = $DB->insert_record('lti_types_config', array('typeid' => $toolid1, 'name' => 'customparameters', 61 'value' => $custom1)); 62 $toolid2 = $DB->insert_record('lti_types', array('course' => $SITE->id, 'baseurl' => '', 'createdby' => $USER->id, 63 'timecreated' => time(), 'timemodified' => time())); 64 $configid2 = $DB->insert_record('lti_types_config', array('typeid' => $toolid2, 'name' => 'customparameters', 65 'value' => $custom2)); 66 67 // Create 2 instances with custom parameters. 68 $activity1 = $ltigenerator->create_instance(array('course' => $SITE->id, 'name' => 'LTI activity 1', 69 'typeid' => $toolid1, 'toolurl' => '', 'instructorcustomparameters' => $custom1)); 70 $activity2 = $ltigenerator->create_instance(array('course' => $SITE->id, 'name' => 'LTI activity 2', 71 'typeid' => $toolid2, 'toolurl' => '', 'instructorcustomparameters' => $custom2)); 72 73 // Run upgrade script. 74 mod_lti_upgrade_custom_separator(); 75 76 // Check semicolon-separated custom parameters have been updated but others have not. 77 $config = $DB->get_record('lti_types_config', array('id' => $configid1)); 78 $this->assertEquals($config->value, $custom2); 79 80 $config = $DB->get_record('lti_types_config', array('id' => $configid2)); 81 $this->assertEquals($config->value, $custom2); 82 83 $config = $DB->get_record('lti', array('id' => $activity1->id)); 84 $this->assertEquals($config->instructorcustomparameters, $custom2); 85 86 $config = $DB->get_record('lti', array('id' => $activity2->id)); 87 $this->assertEquals($config->instructorcustomparameters, $custom2); 88 } 89 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |