19 declare(strict_types=1);
27 $old_email =
'oldemail@ilias.de';
28 $our_token =
hash(
'md5',
'5' .
'-' . $old_email);
29 $new_email =
'newemail@ilias.de';
30 $db_mock = $this->createMock(ilDBInterface::class);
31 $db_mock->expects($this->once())->method(
'replace')->willReturn(1);
33 $user_mock = $this->createMock(\ilObjUser::class);
34 $user_mock->expects($this->once())->method(
'getId')->willReturn(5);
35 $user_mock->expects($this->once())->method(
'getEmail')->willReturn($old_email);
39 $returned_token = $repository->getNewTokenForUser($user_mock, $new_email);
41 $this->assertEquals($returned_token, $our_token);
46 $old_email =
'oldemail@ilias.de';
47 $our_token =
hash(
'md5',
'5' .
'-' . $old_email);
48 $new_email =
'newemail@ilias.de';
49 $db_mock = $this->createMock(ilDBInterface::class);
50 $db_mock->expects($this->once())->method(
'fetchObject')->willReturn((
object) [
'new_email' => $new_email]);
52 $user_mock = $this->createMock(\ilObjUser::class);
53 $user_mock->expects($this->once())->method(
'getId')->willReturn(5);
54 $user_mock->expects($this->once())->method(
'getEmail')->willReturn($old_email);
58 $returned_email = $repository->getNewEmailForUser($user_mock, $our_token);
60 $this->assertEquals($returned_email, $new_email);
65 $old_email =
'oldemail@ilias.de';
66 $our_token =
hash(
'md5',
'5' .
'-' . $old_email);
68 $db_mock = $this->createMock(ilDBInterface::class);
69 $db_mock->expects($this->never())->method(
'fetchObject');
71 $user_mock = $this->createMock(\ilObjUser::class);
72 $user_mock->expects($this->once())->method(
'getId')->willReturn(2);
73 $user_mock->expects($this->once())->method(
'getEmail')->willReturn($old_email);
77 $returned_email = $repository->getNewEmailForUser($user_mock, $our_token);
79 $this->assertEquals($returned_email,
'');
testGetNewTokenForUserReturnsMd5OfUserIdAndEmail()
testGetNewEmailForUserReturnsEmptyStringOnWrongToken()
testGetNewEmailForUserReturnsEmail()