Skip to content

Commit

Permalink
Merge pull request #224 from feuloren/master
Browse files Browse the repository at this point in the history
Methode getUserId pour récupérer l'id à partir du login
  • Loading branch information
mattgu74 committed Jul 23, 2013
2 parents 5f71e46 + e5d5f5f commit c66fc6f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
9 changes: 9 additions & 0 deletions class/ServiceBase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ public function getImage64($img_id, $outw = 0, $outh = 0) {
}
}

/**
* Renvoie l'id d'un utilisateur à partir de son login UTC
*/
public function getUserId($login) {
$this->checkRight();
$user = new User($login);
return $user->getId();
}

protected function &getSession() {
if (!isset($_SESSION[get_class($this)])) {
$_SESSION[get_class($this)] = array();
Expand Down
21 changes: 21 additions & 0 deletions tests/Payutc/Service/ServiceBaseRodbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public function loginApp(&$cookie='', &$r, $key='my_app')
return $r;
}

public function getUserId(&$cookie='', &$r, $login='trecouvr')
{
$r = httpSend('ADMINRIGHT', 'getUserId', $cookie, array(
'login' => $login,
));
return $r;
}

/**
* @requires PHP 5.4
*/
Expand Down Expand Up @@ -74,5 +82,18 @@ public function testLoginApp()
$this->loginApp($cookie, $r, 'my_app');
$this->assertEquals(200, $r->code);
}

/**
* @requires PHP 5.4
*/
public function testGetUserId()
{
$cookie = '';
$r = null;
$this->loginApp($cookie, null, 'my_app');
$this->loginCas($cookie);
$this->getUserId($cookie, $r, 'trecouvr');
$this->assertEquals(1, $r);
}
}

5 changes: 4 additions & 1 deletion tests/seed/applicationright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ tj_app_fun_afu:
app_id: 1
fun_id: 1
afu_service: POSS3

-
app_id: 1
fun_id: 1
afu_service: ADMINRIGHT
5 changes: 4 additions & 1 deletion tests/seed/fundationrights.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ tj_usr_fun_ufu:
usr_id: 1
fun_id: 1
ufu_service: POSS3

-
user_id: 1
fun_id: 1
ufu_service: ADMINRIGHT

0 comments on commit c66fc6f

Please sign in to comment.