]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9660 - Fixed groups matches functions and added unit tests for them..
authorpoltawski <poltawski>
Tue, 1 May 2007 12:03:45 +0000 (12:03 +0000)
committerpoltawski <poltawski>
Tue, 1 May 2007 12:03:45 +0000 (12:03 +0000)
group/db/dbbasicgrouplib.php
group/lib/groupinglib.php
group/simpletest/test_basicgrouplib.php
group/simpletest/test_groupinglib.php

index c8ffb1e4f3206e5539829d158c48f1168be4b7bb..30faeade5139e779024237a3d7a81b299664bb0d 100644 (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;
 }
index e741a5a50c8ee797ead65c3631a4b550ed6bf00d..c882a8a95f6e80abeb824f3232466788431895de 100644 (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;
 }
index 74f029d35a5ebf4e7da50d7c0e2b275772ed2c07..fb55d2e2fed5aa243ca42f617bc671f53bb7a6a9 100644 (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 {
     }
 }
 
-?>
\ No newline at end of file
+?>
index 04881e6957b12270572dc399ced2397092c1c16e..1cbf4d6e7097b492a9e4382d604f2ef2a740360c 100644 (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 {
     }
 }
 
-?>
\ No newline at end of file
+?>