File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -207,4 +207,21 @@ public function removeUserKey($user_id, $key_id)
207207 {
208208 return $ this ->delete ('users/ ' .$ this ->encodePath ($ user_id ).'/keys/ ' .$ this ->encodePath ($ key_id ));
209209 }
210+
211+ /**
212+ * @return mixed
213+ */
214+ public function emails ()
215+ {
216+ return $ this ->get ('user/emails ' );
217+ }
218+
219+ /**
220+ * @param $id
221+ * @return mixed
222+ */
223+ public function email ($ id )
224+ {
225+ return $ this ->get ('user/emails/ ' .$ this ->encodePath ($ id ));
226+ }
210227}
Original file line number Diff line number Diff line change @@ -417,6 +417,41 @@ public function shouldAttemptLogin()
417417 $ this ->assertEquals ($ expectedArray , $ api ->login ('matt ' , 'password ' ));
418418 }
419419
420+ /**
421+ * @test
422+ */
423+ public function shouldGetUserEmails ()
424+ {
425+ $ expectedArray = array (
426+ array ('id ' => 1 , 'email ' => 'foo@bar.baz ' ),
427+ array ('id ' => 2 , 'email ' => 'foo@bar.qux ' ),
428+ );
429+
430+ $ api = $ this ->getApiMock ();
431+ $ api ->expects ($ this ->once ())
432+ ->method ('get ' )
433+ ->with ('user/emails ' )
434+ ->will ($ this ->returnValue ($ expectedArray ));
435+
436+ $ this ->assertEquals ($ expectedArray , $ api ->emails ());
437+ }
438+
439+ /**
440+ * @test
441+ */
442+ public function shouldGetSpecificUserEmail ()
443+ {
444+ $ expectedArray = array ('id ' => 1 , 'email ' => 'foo@bar.baz ' );
445+
446+ $ api = $ this ->getApiMock ();
447+ $ api ->expects ($ this ->once ())
448+ ->method ('get ' )
449+ ->with ('user/emails/1 ' )
450+ ->will ($ this ->returnValue ($ expectedArray ));
451+
452+ $ this ->assertEquals ($ expectedArray , $ api ->email (1 ));
453+ }
454+
420455 protected function getApiClass ()
421456 {
422457 return 'Gitlab\Api\Users ' ;
You can’t perform that action at this time.
0 commit comments