abstract class question_testcase extends advanced_testcase {
- public function assert($expectation, $compare, $message = '') {
- $message = (isset($expectation->message) and $expectation->message !== '') ? $expectation->message : $message;
+ public function assert($expectation, $compare, $notused = '') {
if (get_class($expectation) === 'question_pattern_expectation') {
- $this->assertRegExp($expectation->pattern, $compare, $message);
+ $this->assertRegExp($expectation->pattern, $compare,
+ 'Expected regex ' . $expectation->pattern . ' not found in ' . $compare);
return;
} else if (get_class($expectation) === 'question_no_pattern_expectation') {
- $this->assertNotRegExp($expectation->pattern, $compare, $message);
+ $this->assertNotRegExp($expectation->pattern, $compare,
+ 'Unexpected regex ' . $expectation->pattern . ' found in ' . $compare);
return;
} else if (get_class($expectation) === 'question_contains_tag_with_attributes') {
- $this->assertTag(array('tag'=>$expectation->tag, 'attributes'=>$expectation->expectedvalues), $compare, $message);
+ $this->assertTag(array('tag'=>$expectation->tag, 'attributes'=>$expectation->expectedvalues), $compare,
+ 'Looking for a ' . $expectation->tag . ' with attributes ' . html_writer::attributes($expectation->expectedvalues) . ' in ' . $compare);
foreach ($expectation->forbiddenvalues as $k=>$v) {
$attr = $expectation->expectedvalues;
$attr[$k] = $v;
- $this->assertNotTag(array('tag'=>$expectation->tag, 'attributes'=>$attr), $compare, $message);
+ $this->assertNotTag(array('tag'=>$expectation->tag, 'attributes'=>$attr), $compare,
+ $expectation->tag . ' had a ' . $k . ' attribute that should not be there in ' . $compare);
}
return;
} else if (get_class($expectation) === 'question_contains_tag_with_attribute') {
$attr = array($expectation->attribute=>$expectation->value);
- $this->assertTag(array('tag'=>$expectation->tag, 'attributes'=>$attr), $compare, $message);
+ $this->assertTag(array('tag'=>$expectation->tag, 'attributes'=>$attr), $compare,
+ 'Looking for a ' . $expectation->tag . ' with attribute ' . html_writer::attributes($attr) . ' in ' . $compare);
return;
} else if (get_class($expectation) === 'question_does_not_contain_tag_with_attributes') {
- $this->assertNotTag(array('tag'=>$expectation->tag, 'attributes'=>$expectation->attributes), $compare, $message);
+ $this->assertNotTag(array('tag'=>$expectation->tag, 'attributes'=>$expectation->attributes), $compare,
+ 'Unexpected ' . $expectation->tag . ' with attributes ' . html_writer::attributes($expectation->attributes) . ' found in ' . $compare);
return;
} else if (get_class($expectation) === 'question_contains_select_expectation') {
return;
} else if (get_class($expectation) === 'question_contains_tag_with_contents') {
- $this->assertTag(array('tag'=>$expectation->tag, 'content'=>$expectation->content), $compare, $message);
+ $this->assertTag(array('tag'=>$expectation->tag, 'content'=>$expectation->content), $compare,
+ 'Looking for a ' . $expectation->tag . ' with content ' . $expectation->content . ' in ' . $compare);
return;
}
}
protected function check_current_state($state) {
- $this->assertEquals($this->quba->get_question_state($this->slot), $state,
- 'Questions is in the wrong state: %s.');
+ $this->assertEquals($state, $this->quba->get_question_state($this->slot),
+ 'Questions is in the wrong state.');
}
protected function check_current_mark($mark) {
$this->assertNotNull($this->quba->get_question_mark($this->slot));
}
$this->assertEquals($mark, $this->quba->get_question_mark($this->slot),
- 'Expected mark and actual mark differ: %s.', 0.000001);
+ 'Expected mark and actual mark differ.', 0.000001);
}
}