MDL-9660 - Fixed groups matches functions and added unit tests for them..
This commit is contained in:
@@ -205,7 +205,7 @@ function groups_db_group_matches($courseid, $grp_name, $grp_description) {
|
||||
$records = get_records_sql($sql);
|
||||
$group = false;
|
||||
if ($records) {
|
||||
$group = $records[0];
|
||||
$group = array_shift($records);
|
||||
}
|
||||
return $group;
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ function groups_grouping_matches($courseid, $gg_name, $gg_description) {
|
||||
$records = get_records_sql($sql);
|
||||
$grouping = false;
|
||||
if ($records) {
|
||||
$grouping = $records[0];
|
||||
$grouping = array_shift($records);
|
||||
}
|
||||
return $grouping;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,15 @@ class basicgrouplib_test extends UnitTestCase {
|
||||
$this->assertTrue($this->courseid == groups_get_course($this->groupid));
|
||||
}
|
||||
|
||||
function test_group_matches(){
|
||||
$groupinfo->name = 'Group Testname:' . $this->getLabel();
|
||||
$groupinfo->description = 'Group Test Description:' . $this->getLabel();
|
||||
|
||||
$this->assertTrue($this->groupid = groups_create_group($this->courseid, $groupinfo));
|
||||
$this->assertTrue(groups_group_matches($this->courseid, $groupinfo->name, $groupinfo->description));
|
||||
|
||||
}
|
||||
|
||||
function test_add_member() {
|
||||
// NOTE, interface change on add_member, remove_member.
|
||||
$this->assertTrue(groups_add_member($this->groupid, $this->userid));
|
||||
@@ -82,4 +91,4 @@ class basicgrouplib_test extends UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -64,6 +64,15 @@ class groupinglib_test extends UnitTestCase {
|
||||
$this->assertTrue(groups_set_grouping_settings($this->groupingid, $groupinginfo));
|
||||
}
|
||||
|
||||
function test_groups_grouping_matches(){
|
||||
$groupinginfo->name = 'Grouping Testname:' . $this->getLabel();
|
||||
$groupinginfo->description = 'Grouing Test Description:' . $this->getLabel();
|
||||
|
||||
$this->assertTrue($this->groupingid = groups_create_grouping($this->courseid, $groupinginfo));
|
||||
$this->assertTrue(groups_grouping_matches($this->courseid, $groupinginfo->name, $groupinginfo->description));
|
||||
|
||||
}
|
||||
|
||||
function test_add_group_to_grouping() {
|
||||
$this->assertTrue(groups_add_group_to_grouping($this->groupid, $this->groupingid));
|
||||
$this->assertTrue(groups_belongs_to_grouping($this->groupid, $this->groupingid));
|
||||
@@ -85,4 +94,4 @@ class groupinglib_test extends UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user