summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-31 10:17:55 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-31 10:17:55 +0000
commitd1c4ef504360063936f767c7ab6c251c97c3f41f (patch)
tree893e59db091488a83bdb7d4a58080fc92b4ff634
parent261ce997dae198afb35e3076fc4e694775b2ba29 (diff)
downloadsemanticscuttle-d1c4ef504360063936f767c7ab6c251c97c3f41f.tar.gz
semanticscuttle-d1c4ef504360063936f767c7ab6c251c97c3f41f.tar.bz2
test getObjectUsers() and fix a bug found by the tests
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@484 b3834d28-1941-0410-a4f8-b48e95affb8f
-rw-r--r--src/SemanticScuttle/Service/User.php1
-rw-r--r--tests/UserTest.php46
2 files changed, 47 insertions, 0 deletions
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 3f07242..5affa0b 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -155,6 +155,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return false;
}
+ $users = array();
while ($row = & $this->db->sql_fetchrow($dbresult)) {
$users[] = new SemanticScuttle_Model_User(
$row[$this->getFieldName('primary')],
diff --git a/tests/UserTest.php b/tests/UserTest.php
index 513011b..a68d7dc 100644
--- a/tests/UserTest.php
+++ b/tests/UserTest.php
@@ -53,6 +53,7 @@ class UserTest extends TestBase
protected function setUp()
{
$this->us = SemanticScuttle_Service_Factory::get('User');
+ $this->us->deleteAll();
}
@@ -118,6 +119,51 @@ class UserTest extends TestBase
);
}
+
+
+ /**
+ * Check if getObjectUsers() without any user works
+ *
+ * @return void
+ */
+ public function testGetObjectUsersNone()
+ {
+ $users = $this->us->getObjectUsers();
+ $this->assertEquals(0, count($users));
+ }
+
+
+
+ /**
+ * Check if getObjectUsers() with a single user works
+ *
+ * @return void
+ */
+ public function testGetObjectUsersSingle()
+ {
+ $uid = $this->addUser();
+ $users = $this->us->getObjectUsers();
+ $this->assertEquals(1, count($users));
+ $this->assertType('SemanticScuttle_Model_User', reset($users));
+ }
+
+
+
+ /**
+ * Check if getObjectUsers() with a several users works
+ *
+ * @return void
+ */
+ public function testGetObjectUsersMultiple()
+ {
+ $uid = $this->addUser();
+ $uid2 = $this->addUser();
+ $uid3 = $this->addUser();
+ $users = $this->us->getObjectUsers();
+ $this->assertEquals(3, count($users));
+ $this->assertType('SemanticScuttle_Model_User', reset($users));
+ }
+
}