Skip to content

Commit 95e9089

Browse files
committed
Fix #13 Unit tests.
Explicitly state contextid for search records (Moodle and Totara Generators use different defaults.) Also pass basic record to assertCount as it's having issues parsing the object.
1 parent 14af2a7 commit 95e9089

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/engine_test.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,20 @@ public function test_index() {
124124
public function test_search() {
125125
global $USER, $DB;
126126

127-
$this->generator->create_record();
127+
$record = new \stdClass();
128+
$record->contextid = \context_course::instance(SITEID)->id;
129+
$this->generator->create_record($record);
128130
$record = new \stdClass();
129131
$record->title = "Special title";
132+
$record->contextid = \context_course::instance(SITEID)->id;
130133
$this->generator->create_record($record);
131134

132135
$this->search->index();
133136

134137
$querydata = new stdClass();
135138
$querydata->q = 'message';
136139
$results = $this->search->search($querydata);
137-
$this->assertCount(2, $results);
140+
$this->assertCount(2, array_keys($results));
138141

139142
// Based on core_mocksearch\search\indexer.
140143
$this->assertEquals($USER->id, $results[0]->get('userid'));

0 commit comments

Comments
 (0)