Permalink
Browse files

MDL-32714 workshop - fix broken unit tests

Using a quick and dirty recordset mock. Thanks to Eloy for the
brainpower.
  • Loading branch information...
1 parent f4d4fca commit 4acfacdbf88ef2ef24174ced07218974486e0545 @danpoltawski danpoltawski committed May 14, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 mod/workshop/form/rubric/simpletest/testlib.php
View
15 mod/workshop/form/rubric/simpletest/testlib.php
@@ -49,6 +49,17 @@ public function calculate_peer_grade(array $grades) {
}
}
+/**
+ * Because we are testing with a recordset, implement the bare minimum
+ * mock of a recordset..
+ */
+class moodle_recordset_for_mocked_database {
+ function __construct() {
+ return array();
+ }
+ function close() {}
+}
+
class workshop_rubric_strategy_test extends UnitTestCase {
/** real database */
@@ -73,8 +84,8 @@ public function setUp() {
$context = new stdclass();
$workshop = (object)array('id' => 42, 'strategy' => 'rubric');
$this->workshop = new workshop($workshop, $cm, $course, $context);
- $DB->expectOnce('get_records_sql');
- $DB->setReturnValue('get_records_sql', array());
+ $DB->expectOnce('get_recordset_sql');
+ $DB->setReturnValue('get_recordset_sql', new moodle_recordset_for_mocked_database());
$this->strategy = new testable_workshop_rubric_strategy($this->workshop);
// prepare dimensions definition

0 comments on commit 4acfacd

Please sign in to comment.