/** * * Test KTAPI_User getList(), getById(), getByName, getByUsername() * * @TODO KTAPI_User::getByEmail() */ function testUsers() { // getList() $list = KTAPI_User::getList(); $this->assertTrue(count($list) > 0); // getById() $user = KTAPI_User::getById(1); $this->assertTrue($user->Username == 'admin'); $this->assertTrue($user->Name == 'Administrator'); // getByName() $user = KTAPI_User::getByName('Anonymous'); $this->assertTrue($user->Id == -2); // getByUsername() $user = KTAPI_User::getByUsername('admin'); $this->assertTrue($user->Id == 1); }
/** * Method to return a user based on the name * * @author KnowledgeTree Team * @access public * @param string $name The name of the user * @return array $response The formatted response array */ public function get_user_by_name($name) { $user = KTAPI_User::getByName($name); if (PEAR::isError($user)) { $response['status_code'] = 1; $response['message'] = $user->getMessage(); return $response; } $results = $this->_get_user_details($user); $response['message'] = ''; $response['status_code'] = 0; $response['results'] = $results; return $response; }