Permalink
Browse files

MDL-38147 added comments for SQL-based course search that might not w…

…ork on some DB
  • Loading branch information...
1 parent a32f163 commit 5e71c37ea924c72cb416a27d5d0b4abdbde2633d @marinaglancy marinaglancy committed Mar 27, 2013
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/tests/coursecatlib_test.php
@@ -405,17 +405,25 @@ public function test_get_search_courses() {
// search courses
// search by text
+ $res = coursecat::search_courses(array('search' => 'Test'));
+ $this->assertEquals(array($c4->id, $c3->id, $c1->id, $c8->id, $c5->id), array_keys($res));
+ $this->assertEquals(5, coursecat::search_courses_count(array('search' => 'Test')));
+
+ // search by text with specified offset and limit
+ $options = array('sort' => array('fullname' => 1), 'offset' => 1, 'limit' => 2);
+ $res = coursecat::search_courses(array('search' => 'Test'), $options);
+ $this->assertEquals(array($c4->id, $c5->id), array_keys($res));
+ $this->assertEquals(5, coursecat::search_courses_count(array('search' => 'Test'), $options));
+
+ // IMPORTANT: the tests below may fail on some databases
+ // case-insensitive search
$res = coursecat::search_courses(array('search' => 'test'));
$this->assertEquals(array($c4->id, $c3->id, $c1->id, $c8->id, $c5->id), array_keys($res));
$this->assertEquals(5, coursecat::search_courses_count(array('search' => 'test')));
+ // non-latin language search
$res = coursecat::search_courses(array('search' => 'Математика'));
$this->assertEquals(array($c3->id, $c6->id), array_keys($res));
$this->assertEquals(2, coursecat::search_courses_count(array('search' => 'Математика'), array()));
-
- $options = array('sort' => array('fullname' => 1), 'offset' => 1, 'limit' => 2);
- $res = coursecat::search_courses(array('search' => 'test'), $options);
- $this->assertEquals(array($c4->id, $c5->id), array_keys($res));
- $this->assertEquals(5, coursecat::search_courses_count(array('search' => 'test'), $options));
}
}

0 comments on commit 5e71c37

Please sign in to comment.