Skip to content

Commit

Permalink
MDL-32714 workshop - fix broken unit tests
Browse files Browse the repository at this point in the history
Using a quick and dirty recordset mock. Thanks to Eloy for the
brainpower.
  • Loading branch information
danpoltawski committed May 14, 2012
1 parent f4d4fca commit 4acfacd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mod/workshop/form/rubric/simpletest/testlib.php
Expand Up @@ -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 */
Expand All @@ -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
Expand Down

0 comments on commit 4acfacd

Please sign in to comment.