mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 22:50:19 +01:00
Merge branch 'wip-MDL-64729-master' of https://github.com/Beedell/moodle
This commit is contained in:
commit
de1f00fdbe
@ -1046,8 +1046,8 @@ function glossary_get_entries_search($concept, $courseid) {
|
||||
(cm.course = :courseid1 AND cm.visible = $bypassteacher)) AND
|
||||
g.id = cm.instance AND
|
||||
e.glossaryid = g.id AND
|
||||
( (e.casesensitive != 0 AND LOWER(concept) = :conceptlower) OR
|
||||
(e.casesensitive = 0 and concept = :concept)) AND
|
||||
( (e.casesensitive != 1 AND LOWER(concept) = :conceptlower) OR
|
||||
(e.casesensitive = 1 and concept = :concept)) AND
|
||||
(g.course = :courseid2 OR g.globalglossary = 1) AND
|
||||
e.usedynalink != 0 AND
|
||||
g.usedynalink != 0", $params);
|
||||
|
@ -466,4 +466,41 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotRegExp('/'.$entry16->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry17->concept.'/', $res->content);
|
||||
}
|
||||
|
||||
public function test_glossary_get_entries_search() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
// Turn on glossary autolinking (usedynalink).
|
||||
set_config('glossary_linkentries', 1);
|
||||
$glossarygenerator = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$glossary = $this->getDataGenerator()->create_module('glossary', array('course' => $course->id));
|
||||
// Note this entry is not case sensitive by default (casesensitive = 0).
|
||||
$entry = $glossarygenerator->create_content($glossary);
|
||||
// Check that a search for the concept return the entry.
|
||||
$concept = $entry->concept;
|
||||
$search = glossary_get_entries_search($concept, $course->id);
|
||||
$this->assertCount(1, $search);
|
||||
$foundentry = array_shift($search);
|
||||
$this->assertEquals($foundentry->concept, $entry->concept);
|
||||
// Now try the same search but with a lowercase term.
|
||||
$concept = strtolower($entry->concept);
|
||||
$search = glossary_get_entries_search($concept, $course->id);
|
||||
$this->assertCount(1, $search);
|
||||
$foundentry = array_shift($search);
|
||||
$this->assertEquals($foundentry->concept, $entry->concept);
|
||||
|
||||
// Make an entry that is case sensitive (casesensitive = 1).
|
||||
set_config('glossary_casesensitive', 1);
|
||||
$entry = $glossarygenerator->create_content($glossary);
|
||||
$concept = $entry->concept;
|
||||
$search = glossary_get_entries_search($concept, $course->id);
|
||||
$this->assertCount(1, $search);
|
||||
$foundentry = array_shift($search);
|
||||
$this->assertEquals($foundentry->concept, $entry->concept);
|
||||
// Now try the same search but with a lowercase term.
|
||||
$concept = strtolower($entry->concept);
|
||||
$search = glossary_get_entries_search($concept, $course->id);
|
||||
$this->assertCount(0, $search);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user