MDL-19976 Changing redirect($url->out()) to redirect($url). NEVER, NEVER use redirect...
[moodle.git] / mod / quiz / report / simpletest / testreportlib.php
CommitLineData
e815151e 1<?php
2/**
3 * Unit tests for (some of) mod/quiz/report/reportlib.php
4 *
5 * @author me@jamiep.org
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7 * @package quiz
8 */
9
10/** */
11require_once(dirname(__FILE__) . '/../../../../config.php');
12
13global $CFG;
14require_once($CFG->libdir . '/simpletestlib.php'); // Include the test libraries
15require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the code to test
16
24572549 17/** This class contains the test cases for the functions in reportlib.php. */
e815151e 18class question_reportlib_test extends UnitTestCase {
ce40c8ff 19 public static $includecoverage = array('mod/quiz/report/reportlib.php');
e815151e 20 function test_quiz_report_index_by_keys() {
21 $datum = array();
22 $object = new object();
23 $object->qid = 3;
24 $object->aid = 101;
25 $object->response = '';
26 $object->grade = 3;
27 $datum[] = $object;
28
29 $indexed = quiz_report_index_by_keys($datum, array('aid','qid'));
30
31 $this->assertEqual($indexed[101][3]->qid, 3);
32 $this->assertEqual($indexed[101][3]->aid, 101);
33 $this->assertEqual($indexed[101][3]->response, '');
34 $this->assertEqual($indexed[101][3]->grade, 3);
35
36 $indexed = quiz_report_index_by_keys($datum, array('aid','qid'), false);
37
38 $this->assertEqual($indexed[101][3][0]->qid, 3);
39 $this->assertEqual($indexed[101][3][0]->aid, 101);
40 $this->assertEqual($indexed[101][3][0]->response, '');
41 $this->assertEqual($indexed[101][3][0]->grade, 3);
42
43 }
44}
ce40c8ff 45?>