mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-17002 "unit test to test quiz_report_index_by_keys"
This commit is contained in:
parent
ba1ff79a76
commit
e815151ead
44
mod/quiz/report/simpletest/testreportlib.php
Normal file
44
mod/quiz/report/simpletest/testreportlib.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit tests for (some of) mod/quiz/report/reportlib.php
|
||||
*
|
||||
* @author me@jamiep.org
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package quiz
|
||||
*/
|
||||
|
||||
/** */
|
||||
require_once(dirname(__FILE__) . '/../../../../config.php');
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/simpletestlib.php'); // Include the test libraries
|
||||
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the code to test
|
||||
|
||||
/** This class contains the test cases for the functions in editlib.php. */
|
||||
class question_reportlib_test extends UnitTestCase {
|
||||
function test_quiz_report_index_by_keys() {
|
||||
$datum = array();
|
||||
$object = new object();
|
||||
$object->qid = 3;
|
||||
$object->aid = 101;
|
||||
$object->response = '';
|
||||
$object->grade = 3;
|
||||
$datum[] = $object;
|
||||
|
||||
$indexed = quiz_report_index_by_keys($datum, array('aid','qid'));
|
||||
|
||||
$this->assertEqual($indexed[101][3]->qid, 3);
|
||||
$this->assertEqual($indexed[101][3]->aid, 101);
|
||||
$this->assertEqual($indexed[101][3]->response, '');
|
||||
$this->assertEqual($indexed[101][3]->grade, 3);
|
||||
|
||||
$indexed = quiz_report_index_by_keys($datum, array('aid','qid'), false);
|
||||
|
||||
$this->assertEqual($indexed[101][3][0]->qid, 3);
|
||||
$this->assertEqual($indexed[101][3][0]->aid, 101);
|
||||
$this->assertEqual($indexed[101][3][0]->response, '');
|
||||
$this->assertEqual($indexed[101][3][0]->grade, 3);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user