diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-30 15:12:02 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-30 15:12:02 +0300 |
commit | 32b577a5df926b7de030e6d7abb5c7fe2f1c171a (patch) | |
tree | b56426504fcd989d55420ed734e9ab33d966b3b0 /apps/user_status/tests | |
parent | aeb7329b3db0b1cbfa41bdedf9bccb230a3910d8 (diff) |
Reset the user status when clearing the custom message
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_status/tests')
-rw-r--r-- | apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php index 5d1e15b0d3e..fbf86ba92c4 100644 --- a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php +++ b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php @@ -243,6 +243,7 @@ class UserStatusControllerTest extends TestCase { * @param Throwable|null $exception * @param bool $expectLogger * @param string|null $expectedLogMessage + * @param bool $expectSuccessAsReset * * @dataProvider setCustomMessageDataProvider */ @@ -253,7 +254,8 @@ class UserStatusControllerTest extends TestCase { bool $expectException, ?Throwable $exception, bool $expectLogger, - ?string $expectedLogMessage): void { + ?string $expectedLogMessage, + bool $expectSuccessAsReset = false): void { $userStatus = $this->getUserStatus(); if ($expectException) { @@ -262,10 +264,25 @@ class UserStatusControllerTest extends TestCase { ->with('john.doe', $statusIcon, $message, $clearAt) ->willThrowException($exception); } else { - $this->service->expects($this->once()) - ->method('setCustomMessage') - ->with('john.doe', $statusIcon, $message, $clearAt) - ->willReturn($userStatus); + if ($expectSuccessAsReset) { + $this->service->expects($this->never()) + ->method('setCustomMessage'); + $this->service->expects($this->once()) + ->method('clearMessage') + ->with('john.doe'); + $this->service->expects($this->once()) + ->method('findByUserId') + ->with('john.doe') + ->willReturn($userStatus); + } else { + $this->service->expects($this->once()) + ->method('setCustomMessage') + ->with('john.doe', $statusIcon, $message, $clearAt) + ->willReturn($userStatus); + + $this->service->expects($this->never()) + ->method('clearMessage'); + } } if ($expectLogger) { @@ -297,6 +314,7 @@ class UserStatusControllerTest extends TestCase { public function setCustomMessageDataProvider(): array { return [ ['👨🏽💻', 'Busy developing the status feature', 500, true, false, null, false, null], + ['👨🏽💻', '', 500, true, false, null, false, null, true], ['👨🏽💻', 'Busy developing the status feature', 500, false, true, new InvalidClearAtException('Original exception message'), true, 'New user-status for "john.doe" was rejected due to an invalid clearAt value "500"'], ['👨🏽💻', 'Busy developing the status feature', 500, false, true, new InvalidStatusIconException('Original exception message'), true, |