[ 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 * Unit tests for the quizaccess_safebrowser plugin. 19 * 20 * @package quizaccess 21 * @subpackage safebrowser 22 * @category phpunit 23 * @copyright 2008 The Open University 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 global $CFG; 31 require_once($CFG->dirroot . '/mod/quiz/accessrule/safebrowser/rule.php'); 32 33 34 /** 35 * Unit tests for the quizaccess_safebrowser plugin. 36 * 37 * @copyright 2008 The Open University 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class quizaccess_safebrowser_testcase extends basic_testcase { 41 // Nothing very testable in this class, just test that it obeys the general access rule contact. 42 public function test_safebrowser_access_rule() { 43 $quiz = new stdClass(); 44 $quiz->browsersecurity = 'safebrowser'; 45 $cm = new stdClass(); 46 $cm->id = 0; 47 $quizobj = new quiz($quiz, $cm, null); 48 $rule = new quizaccess_safebrowser($quizobj, 0); 49 $attempt = new stdClass(); 50 51 // This next test assumes the unit tests are not being run using Safe Exam Browser! 52 $_SERVER['HTTP_USER_AGENT'] = 'unknonw browser'; 53 $this->assertEquals(get_string('safebrowsererror', 'quizaccess_safebrowser'), 54 $rule->prevent_access()); 55 56 $this->assertEquals(get_string('safebrowsernotice', 'quizaccess_safebrowser'), 57 $rule->description()); 58 $this->assertFalse($rule->prevent_new_attempt(0, $attempt)); 59 $this->assertFalse($rule->is_finished(0, $attempt)); 60 $this->assertFalse($rule->end_time($attempt)); 61 $this->assertFalse($rule->time_left_display($attempt, 0)); 62 } 63 }
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 |