Skip to content

Commit

Permalink
MDL-9660 - Fixed groups matches functions and added unit tests for th…
Browse files Browse the repository at this point in the history
…em..
  • Loading branch information
poltawski committed May 1, 2007
1 parent 9e2e594 commit 5fe855d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion group/db/dbbasicgrouplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion group/lib/groupinglib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion group/simpletest/test_basicgrouplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ function test_create_group() {
$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));
Expand All @@ -82,4 +91,4 @@ function test_delete_group() {
}
}

?>
?>
11 changes: 10 additions & 1 deletion group/simpletest/test_groupinglib.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ function test_create_grouping() {
$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));
Expand All @@ -85,4 +94,4 @@ function test_delete_grouping() {
}
}

?>
?>

0 comments on commit 5fe855d

Please sign in to comment.