|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 require_once($CFG->dirroot . '/mod/quiz/editlib.php'); 00030 00031 00038 class quiz_editlib_test extends UnitTestCase { 00039 public static $includecoverage = array('mod/quiz/editlib.php'); 00040 public function test_quiz_move_question_up() { 00041 $this->assertEqual(quiz_move_question_up('0', 123), '0'); 00042 $this->assertEqual(quiz_move_question_up('1,2,0', 1), '1,2,0'); 00043 $this->assertEqual(quiz_move_question_up('1,2,0', 0), '1,2,0'); 00044 $this->assertEqual(quiz_move_question_up('1,2,0', 2), '2,1,0'); 00045 $this->assertEqual(quiz_move_question_up('1,2,0,3,4,0', 3), '1,2,3,0,4,0'); 00046 $this->assertEqual(quiz_move_question_up('1,2,3,0,4,0', 4), '1,2,3,4,0,0'); 00047 } 00048 00049 public function test_quiz_move_question_down() { 00050 $this->assertEqual(quiz_move_question_down('0', 123), '0'); 00051 $this->assertEqual(quiz_move_question_down('1,2,0', 2), '1,2,0'); 00052 $this->assertEqual(quiz_move_question_down('1,2,0', 0), '1,2,0'); 00053 $this->assertEqual(quiz_move_question_down('1,2,0', 1), '2,1,0'); 00054 $this->assertEqual(quiz_move_question_down('1,2,0,3,4,0', 2), '1,0,2,3,4,0'); 00055 $this->assertEqual(quiz_move_question_down('1,0,2,3,0,4,0', 1), '0,1,2,3,0,4,0'); 00056 } 00057 00058 public function test_quiz_delete_empty_page() { 00059 $this->assertEqual(quiz_delete_empty_page('0', 0), '0'); 00060 $this->assertEqual(quiz_delete_empty_page('1,2,0', 2), '1,2,0'); 00061 $this->assertEqual(quiz_delete_empty_page('0,1,2,0', -1), '1,2,0'); 00062 $this->assertEqual(quiz_delete_empty_page('0,1,2,0', 0), '0,1,2,0'); 00063 $this->assertEqual(quiz_delete_empty_page('1,2,0', 3), '1,2,0'); 00064 $this->assertEqual(quiz_delete_empty_page('1,2,0', -1), '1,2,0'); 00065 $this->assertEqual(quiz_delete_empty_page('1,2,0,0', 2), '1,2,0'); 00066 $this->assertEqual(quiz_delete_empty_page('1,2,0,0', 1), '1,2,0,0'); 00067 $this->assertEqual(quiz_delete_empty_page('1,2,0,0,3,4,0', 2), '1,2,0,3,4,0'); 00068 $this->assertEqual(quiz_delete_empty_page('0,0,1,2,0', 0), '0,1,2,0'); 00069 } 00070 00071 public function test_quiz_add_page_break_after() { 00072 $this->assertEqual(quiz_add_page_break_after('0', 1), '0'); 00073 $this->assertEqual(quiz_add_page_break_after('1,2,0', 1), '1,0,2,0'); 00074 $this->assertEqual(quiz_add_page_break_after('1,2,0', 2), '1,2,0,0'); 00075 $this->assertEqual(quiz_add_page_break_after('1,2,0', 0), '1,2,0'); 00076 } 00077 00078 public function test_quiz_add_page_break_at() { 00079 $this->assertEqual(quiz_add_page_break_at('0', 0), '0,0'); 00080 $this->assertEqual(quiz_add_page_break_at('1,2,0', 0), '0,1,2,0'); 00081 $this->assertEqual(quiz_add_page_break_at('1,2,0', 1), '1,0,2,0'); 00082 $this->assertEqual(quiz_add_page_break_at('1,2,0', 2), '1,2,0,0'); 00083 $this->assertEqual(quiz_add_page_break_at('1,2,0', 3), '1,2,0'); 00084 } 00085 }