-
Notifications
You must be signed in to change notification settings - Fork 295
add unit tests for UserDeletedListener functionality #12114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add unit tests for UserDeletedListener functionality #12114
Conversation
Added comprehensive unit tests for the UserDeletedListener to ensure proper handling of user deletion events, including scenarios with no accounts, single and multiple accounts, client exceptions, and partial failures. This enhances test coverage and reliability of the mail account deletion process. Signed-off-by: Misha M.-Kupriyanov <[email protected]>
kesselb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏
Some smaller nitpicks, but overall a good initiative to add a test for it.
| $this->assertInstanceOf(\OCP\EventDispatcher\IEventListener::class, $this->listener); | ||
| } | ||
|
|
||
| public function testHandleMethodHasOverrideAttribute(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you have a test for that?
| ); | ||
| } | ||
|
|
||
| private function createUserMock(string $userId = 'test-user'): IUser&MockObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private function createUserMock(string $userId = 'test-user'): IUser&MockObject { | |
| private function createUserMock(string $userId): IUser&MockObject { |
Not using a default makes the test easier to read because the value is given when used.
| } | ||
|
|
||
| private function createAccountMock(int $id): Account&MockObject { | ||
| $account = $this->createMock(Account::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Account is mostly an DTO. Nicer would be, because we are not working with a test double, to instantiate a new object and only mock the MailAccount object.
Added comprehensive unit tests for the UserDeletedListener to ensure proper handling of user deletion events, including scenarios with no accounts, single and multiple accounts, client exceptions, and partial failures. This enhances test coverage and reliability of the mail account deletion process.
In order for us to extend the logic in the future