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 core_question; 18 19 use question_bank; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 global $CFG; 24 require_once($CFG->dirroot . '/question/type/questiontypebase.php'); 25 26 27 /** 28 * Tests for some of ../questionbase.php 29 * 30 * @package core_question 31 * @copyright 2008 The Open University 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 * 34 * @covers \question_type 35 */ 36 class question_type_test extends \advanced_testcase { 37 public function test_save_question_name() { 38 $this->resetAfterTest(); 39 40 $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); 41 $cat = $questiongenerator->create_question_category(array()); 42 43 $saq = $questiongenerator->create_question('shortanswer', null, 44 array('category' => $cat->id, 'name' => 'Test question')); 45 $actual = question_bank::load_question_data($saq->id); 46 47 $this->assertSame('Test question', $actual->name); 48 } 49 50 public function test_save_question_zero_name() { 51 $this->resetAfterTest(); 52 53 $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); 54 $cat = $questiongenerator->create_question_category(array()); 55 56 $saq = $questiongenerator->create_question('shortanswer', null, 57 array('category' => $cat->id, 'name' => '0')); 58 $actual = question_bank::load_question_data($saq->id); 59 60 $this->assertSame('0', $actual->name); 61 } 62 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body