File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ public function getUuid():string {
8383 return $ userData ->getUuid ();
8484 }
8585
86+ public function getEmail ():string {
87+ $ userData = $ this ->sessionData ->getUserData ();
88+ return $ userData ->getEmail ();
89+ }
90+
8691 private function authInProgress ():bool {
8792 return false ;
8893 }
Original file line number Diff line number Diff line change 33
44class UserData {
55 private string $ uuid ;
6+ private string $ email ;
67
78 public function getUuid ():string {
89 return $ this ->uuid ;
910 }
11+
12+ public function getEmail ():string {
13+ return $ this ->email ;
14+ }
1015}
Original file line number Diff line number Diff line change @@ -201,4 +201,36 @@ public function testGetUuid() {
201201 );
202202 self ::assertEquals ($ expectedUuid , $ sut ->getUuid ());
203203 }
204+
205+ public function testGetEmailThrowsExceptionWhenNotLoggedIn () {
206+ $ _SESSION = [];
207+ $ sut = new Authenticator (
208+ "test-key " ,
209+ "test-secret " ,
210+ "/ "
211+ );
212+ self ::expectException (NotLoggedInException::class);
213+ $ sut ->getEmail ();
214+ }
215+
216+ public function testGetEmail () {
217+ $ expectedEmail = "example@example.com " ;
218+
219+ $ userData = self ::createMock (UserData::class);
220+ $ userData ->method ("getEmail " )
221+ ->willReturn ($ expectedEmail );
222+ $ sessionData = self ::createMock (SessionData::class);
223+ $ sessionData ->method ("getUserData " )
224+ ->willReturn ($ userData );
225+
226+ $ _SESSION = [
227+ Authenticator::SESSION_KEY => $ sessionData ,
228+ ];
229+ $ sut = new Authenticator (
230+ "test-key " ,
231+ "test-secret " ,
232+ "/ "
233+ );
234+ self ::assertEquals ($ expectedEmail , $ sut ->getEmail ());
235+ }
204236}
You can’t perform that action at this time.
0 commit comments