-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not change the old behavior of user creation
- Loading branch information
1 parent
0dd2a2e
commit 76c356c
Showing
4 changed files
with
46 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,20 +116,22 @@ public function testAddUserToGroups() { | |
} | ||
|
||
/** | ||
* @expectedExceptionMessage Invalid mail address | ||
* @expectedException \OCP\User\Exceptions\InvalidEmailException | ||
*/ | ||
public function testInvalidEmail() { | ||
$this->expectException(\OCP\User\Exceptions\InvalidEmailException::class); | ||
$this->expectExceptionMessage('Invalid mail address'); | ||
|
||
$this->mailer->method('validateMailAddress') | ||
->willReturn(false); | ||
$this->createUserService->createUser(['username' => 'foo', 'password' => '', 'email' => 'foo@bar']); | ||
} | ||
|
||
/** | ||
* @expectedExceptionMessage A user with that name already exists. | ||
* @expectedException \OCP\User\Exceptions\UserAlreadyExistsException | ||
*/ | ||
public function testAlreadyExistingUser() { | ||
$this->expectException(\OCP\User\Exceptions\UserAlreadyExistsException::class); | ||
$this->expectExceptionMessage('A user with that name already exists.'); | ||
|
||
$this->userSendMailService->method('validateEmailAddress') | ||
->willReturn(true); | ||
|
||
|
@@ -140,26 +142,28 @@ public function testAlreadyExistingUser() { | |
} | ||
|
||
/** | ||
* @expectedExceptionMessage Unable to create user due to exception: | ||
* @expectedException \OCP\User\Exceptions\CannotCreateUserException | ||
*/ | ||
public function testUserCreateException() { | ||
$this->expectException(\OCP\User\Exceptions\CannotCreateUserException::class); | ||
$this->expectExceptionMessage('Exception Message'); | ||
|
||
$this->userSendMailService->method('validateEmailAddress') | ||
->willReturn(true); | ||
|
||
$this->userManager->method('userExists') | ||
->willReturn(false); | ||
|
||
$this->userManager->method('createUser') | ||
->willThrowException(new \Exception()); | ||
->willThrowException(new \Exception("Exception Message")); | ||
$this->createUserService->createUser(['username' => 'foo', 'password' => '', 'email' => '[email protected]']); | ||
} | ||
|
||
/** | ||
* @expectedExceptionMessage Unable to create user. | ||
* @expectedException \OCP\User\Exceptions\CannotCreateUserException | ||
*/ | ||
public function testUserCreateFailed() { | ||
$this->expectException(\OCP\User\Exceptions\CannotCreateUserException::class); | ||
$this->expectExceptionMessage('Unable to create user.'); | ||
|
||
$this->userSendMailService->method('validateEmailAddress') | ||
->willReturn(true); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,10 +99,11 @@ public function testGenerateTokenAndSendMail() { | |
} | ||
|
||
/** | ||
* @expectedException OCP\User\Exceptions\InvalidUserTokenException | ||
* @expectedExceptionMessage The token provided is invalid. | ||
*/ | ||
public function testcheckPasswordSetInvalidToken() { | ||
$this->expectException(\OCP\User\Exceptions\InvalidUserTokenException::class); | ||
$this->expectExceptionMessage('The token provided is invalid.'); | ||
|
||
$user = $this->createMock(IUser::class); | ||
$user->method('getUID') | ||
->willReturn('foo'); | ||
|
@@ -113,10 +114,11 @@ public function testcheckPasswordSetInvalidToken() { | |
} | ||
|
||
/** | ||
* @expectedException \OCP\User\Exceptions\UserTokenExpiredException | ||
* @expectedExceptionMessage The token provided had expired. | ||
*/ | ||
public function testCheckPasswordSetTokenExpired() { | ||
$this->expectException(\OCP\User\Exceptions\UserTokenExpiredException::class); | ||
$this->expectExceptionMessage('The token provided had expired.'); | ||
|
||
$user = $this->createMock(IUser::class); | ||
$user->method('getUID') | ||
->willReturn('foo'); | ||
|
@@ -133,10 +135,11 @@ public function testCheckPasswordSetTokenExpired() { | |
} | ||
|
||
/** | ||
* @expectedException \OCP\User\Exceptions\UserTokenMismatchException | ||
* @expectedExceptionMessage The token provided is invalid. | ||
*/ | ||
public function testCheckPasswordSetTokenMismatch() { | ||
$this->expectException(\OCP\User\Exceptions\UserTokenMismatchException::class); | ||
$this->expectExceptionMessage('The token provided is invalid.'); | ||
|
||
$user = $this->createMock(IUser::class); | ||
$user->method('getUID') | ||
->willReturn('foo'); | ||
|
@@ -187,10 +190,11 @@ public function testSendNotificationMailFail() { | |
} | ||
|
||
/** | ||
* @expectedException \OCP\User\Exceptions\EmailSendFailedException | ||
* @expectedExceptionMessage Email could not be sent. | ||
*/ | ||
public function testSendNotificationMailSendFail() { | ||
$this->expectException(\OCP\User\Exceptions\EmailSendFailedException::class); | ||
$this->expectExceptionMessage('Email could not be sent.'); | ||
|
||
$user = $this->createMock(IUser::class); | ||
$user->method('getEMailAddress') | ||
->willReturn('[email protected]'); | ||
|