MDL-9660 - Fixed groups matches functions and added unit tests for them..

This commit is contained in:
poltawski
2007-05-01 12:03:45 +00:00
parent 9e2e5943dc
commit 5fe855d178
4 changed files with 22 additions and 4 deletions
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+10 -1
View File
@@ -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 {
}
}
?>
?>
+10 -1
View File
@@ -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 {
}
}
?>
?>