MDL-42913 lib/grouplib.php: Avoid cache sometimes for groups_get_all_groups

The new groups cache returns unexpected results when you pass
in a field parameter than would normally change the result array index
This commit is contained in:
Aaron Barnes
2013-11-20 11:56:42 +13:00
parent b58bc15af5
commit 2eaa440c34
2 changed files with 24 additions and 6 deletions
+12
View File
@@ -26,6 +26,10 @@
defined('MOODLE_INTERNAL') || die();
/**
* Unit tests for lib/grouplib.php
* @group core_group
*/
class core_grouplib_testcase extends advanced_testcase {
public function test_groups_get_group_by_idnumber() {
@@ -404,6 +408,14 @@ class core_grouplib_testcase extends advanced_testcase {
$this->assertNotContains($group2->id, $groupkeys);
$this->assertContains($group3->id, $groupkeys);
$this->assertContains($group4->id, $groupkeys);
// Test this function using an alternate column for the result index
$groups = groups_get_all_groups($course->id, null, $grouping2->id, 'g.name, g.id');
$groupkeys = array_keys($groups);
$this->assertCount(2, $groups);
$this->assertNotContains($group3->id, $groupkeys);
$this->assertContains($group3->name, $groupkeys);
$this->assertEquals($group3->id, $groups[$group3->name]->id);
}
/**