From 3240fd960991daf807d69f3ee7978d8a935d926d Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 26 Mar 2009 08:42:23 +0000 Subject: [PATCH] questions: unit tests for default_questiontype::compare_responses. --- question/type/simpletest/testquestiontype.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 question/type/simpletest/testquestiontype.php diff --git a/question/type/simpletest/testquestiontype.php b/question/type/simpletest/testquestiontype.php new file mode 100644 index 0000000000..5a8bf4aedf --- /dev/null +++ b/question/type/simpletest/testquestiontype.php @@ -0,0 +1,73 @@ +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)); + } +} + +?> -- 2.39.5