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
This commit is contained in:
cweiske 2009-10-31 10:17:55 +00:00
parent 261ce997da
commit d1c4ef5043
2 changed files with 47 additions and 0 deletions

View file

@ -155,6 +155,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return false; return false;
} }
$users = array();
while ($row = & $this->db->sql_fetchrow($dbresult)) { while ($row = & $this->db->sql_fetchrow($dbresult)) {
$users[] = new SemanticScuttle_Model_User( $users[] = new SemanticScuttle_Model_User(
$row[$this->getFieldName('primary')], $row[$this->getFieldName('primary')],

View file

@ -53,6 +53,7 @@ class UserTest extends TestBase
protected function setUp() protected function setUp()
{ {
$this->us = SemanticScuttle_Service_Factory::get('User'); $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));
}
} }