mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
questions: unit tests for default_questiontype::compare_responses.
- Loading branch information
tjhunt
committed
Mar 26, 2009
1 parent
8d96a7b
commit 3240fd9
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php // $Id$ | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// NOTICE OF COPYRIGHT // | ||
// // | ||
// Moodle - Modular Object-Oriented Dynamic Learning Environment // | ||
// http://moodle.org // | ||
// // | ||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // | ||
// // | ||
// This program is free software; you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation; either version 2 of the License, or // | ||
// (at your option) any later version. // | ||
// // | ||
// This program is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details: // | ||
// // | ||
// http://www.gnu.org/copyleft/gpl.html // | ||
// // | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Tests for some of ../questiontype.php | ||
* | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License | ||
* @package moodlecore | ||
*/ | ||
|
||
if (!defined('MOODLE_INTERNAL')) { | ||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page | ||
} | ||
|
||
require_once($CFG->dirroot . '/question/type/questiontype.php'); | ||
|
||
class default_questiontype_test extends UnitTestCase { | ||
protected $qtype; | ||
|
||
public function setUp() { | ||
$this->qtype = new default_questiontype(); | ||
} | ||
|
||
public function tearDown() { | ||
$this->qtype = null; | ||
} | ||
|
||
function test_compare_responses() { | ||
$question = new stdClass; | ||
$state = new stdClass; | ||
$teststate = new stdClass; | ||
|
||
$state->responses = array(); | ||
$teststate->responses = array(); | ||
$this->assertTrue($this->qtype->compare_responses($question, $state, $teststate)); | ||
|
||
$state->responses = array('' => 'frog'); | ||
$teststate->responses = array('' => 'toad'); | ||
$this->assertFalse($this->qtype->compare_responses($question, $state, $teststate)); | ||
|
||
$state->responses = array('x' => 'frog'); | ||
$teststate->responses = array('y' => 'frog'); | ||
$this->assertFalse($this->qtype->compare_responses($question, $state, $teststate)); | ||
|
||
$state->responses = array(1 => 1, 2 => 2); | ||
$teststate->responses = array(2 => 2, 1 => 1); | ||
$this->assertTrue($this->qtype->compare_responses($question, $state, $teststate)); | ||
} | ||
} | ||
|
||
?> |