|
|
|
|
@ -31,27 +31,13 @@ use Psr\Log\LoggerInterface;
|
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
class StatusServiceTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
/** @var UserStatusMapper|MockObject */
|
|
|
|
|
private $mapper;
|
|
|
|
|
|
|
|
|
|
/** @var ITimeFactory|MockObject */
|
|
|
|
|
private $timeFactory;
|
|
|
|
|
|
|
|
|
|
/** @var PredefinedStatusService|MockObject */
|
|
|
|
|
private $predefinedStatusService;
|
|
|
|
|
|
|
|
|
|
/** @var IEmojiHelper|MockObject */
|
|
|
|
|
private $emojiHelper;
|
|
|
|
|
|
|
|
|
|
/** @var IConfig|MockObject */
|
|
|
|
|
private $config;
|
|
|
|
|
|
|
|
|
|
/** @var IUserManager|MockObject */
|
|
|
|
|
private $userManager;
|
|
|
|
|
|
|
|
|
|
/** @var LoggerInterface|MockObject */
|
|
|
|
|
private $logger;
|
|
|
|
|
private UserStatusMapper&MockObject $mapper;
|
|
|
|
|
private ITimeFactory&MockObject $timeFactory;
|
|
|
|
|
private PredefinedStatusService&MockObject $predefinedStatusService;
|
|
|
|
|
private IEmojiHelper&MockObject $emojiHelper;
|
|
|
|
|
private IConfig&MockObject $config;
|
|
|
|
|
private IUserManager&MockObject $userManager;
|
|
|
|
|
private LoggerInterface&MockObject $logger;
|
|
|
|
|
|
|
|
|
|
private StatusService $service;
|
|
|
|
|
|
|
|
|
|
@ -236,20 +222,10 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $userId
|
|
|
|
|
* @param string $status
|
|
|
|
|
* @param int|null $statusTimestamp
|
|
|
|
|
* @param bool $isUserDefined
|
|
|
|
|
* @param bool $expectExisting
|
|
|
|
|
* @param bool $expectSuccess
|
|
|
|
|
* @param bool $expectTimeFactory
|
|
|
|
|
* @param bool $expectException
|
|
|
|
|
* @param string|null $expectedExceptionClass
|
|
|
|
|
* @param string|null $expectedExceptionMessage
|
|
|
|
|
*
|
|
|
|
|
* @dataProvider setStatusDataProvider
|
|
|
|
|
*/
|
|
|
|
|
public function testSetStatus(string $userId,
|
|
|
|
|
public function testSetStatus(
|
|
|
|
|
string $userId,
|
|
|
|
|
string $status,
|
|
|
|
|
?int $statusTimestamp,
|
|
|
|
|
bool $isUserDefined,
|
|
|
|
|
@ -258,7 +234,8 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
bool $expectTimeFactory,
|
|
|
|
|
bool $expectException,
|
|
|
|
|
?string $expectedExceptionClass,
|
|
|
|
|
?string $expectedExceptionMessage): void {
|
|
|
|
|
?string $expectedExceptionMessage,
|
|
|
|
|
): void {
|
|
|
|
|
$userStatus = new UserStatus();
|
|
|
|
|
|
|
|
|
|
if ($expectExisting) {
|
|
|
|
|
@ -309,7 +286,7 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setStatusDataProvider(): array {
|
|
|
|
|
public static function setStatusDataProvider(): array {
|
|
|
|
|
return [
|
|
|
|
|
['john.doe', 'online', 50, true, true, true, false, false, null, null],
|
|
|
|
|
['john.doe', 'online', 50, true, false, true, false, false, null, null],
|
|
|
|
|
@ -368,19 +345,10 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $userId
|
|
|
|
|
* @param string $messageId
|
|
|
|
|
* @param bool $isValidMessageId
|
|
|
|
|
* @param int|null $clearAt
|
|
|
|
|
* @param bool $expectExisting
|
|
|
|
|
* @param bool $expectSuccess
|
|
|
|
|
* @param bool $expectException
|
|
|
|
|
* @param string|null $expectedExceptionClass
|
|
|
|
|
* @param string|null $expectedExceptionMessage
|
|
|
|
|
*
|
|
|
|
|
* @dataProvider setPredefinedMessageDataProvider
|
|
|
|
|
*/
|
|
|
|
|
public function testSetPredefinedMessage(string $userId,
|
|
|
|
|
public function testSetPredefinedMessage(
|
|
|
|
|
string $userId,
|
|
|
|
|
string $messageId,
|
|
|
|
|
bool $isValidMessageId,
|
|
|
|
|
?int $clearAt,
|
|
|
|
|
@ -388,7 +356,8 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
bool $expectSuccess,
|
|
|
|
|
bool $expectException,
|
|
|
|
|
?string $expectedExceptionClass,
|
|
|
|
|
?string $expectedExceptionMessage): void {
|
|
|
|
|
?string $expectedExceptionMessage,
|
|
|
|
|
): void {
|
|
|
|
|
$userStatus = new UserStatus();
|
|
|
|
|
|
|
|
|
|
if ($expectExisting) {
|
|
|
|
|
@ -451,7 +420,7 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setPredefinedMessageDataProvider(): array {
|
|
|
|
|
public static function setPredefinedMessageDataProvider(): array {
|
|
|
|
|
return [
|
|
|
|
|
['john.doe', 'sick-leave', true, null, true, true, false, null, null],
|
|
|
|
|
['john.doe', 'sick-leave', true, null, false, true, false, null, null],
|
|
|
|
|
@ -465,20 +434,10 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $userId
|
|
|
|
|
* @param string|null $statusIcon
|
|
|
|
|
* @param bool $supportsEmoji
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @param int|null $clearAt
|
|
|
|
|
* @param bool $expectExisting
|
|
|
|
|
* @param bool $expectSuccess
|
|
|
|
|
* @param bool $expectException
|
|
|
|
|
* @param string|null $expectedExceptionClass
|
|
|
|
|
* @param string|null $expectedExceptionMessage
|
|
|
|
|
*
|
|
|
|
|
* @dataProvider setCustomMessageDataProvider
|
|
|
|
|
*/
|
|
|
|
|
public function testSetCustomMessage(string $userId,
|
|
|
|
|
public function testSetCustomMessage(
|
|
|
|
|
string $userId,
|
|
|
|
|
?string $statusIcon,
|
|
|
|
|
bool $supportsEmoji,
|
|
|
|
|
string $message,
|
|
|
|
|
@ -487,7 +446,8 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
bool $expectSuccess,
|
|
|
|
|
bool $expectException,
|
|
|
|
|
?string $expectedExceptionClass,
|
|
|
|
|
?string $expectedExceptionMessage): void {
|
|
|
|
|
?string $expectedExceptionMessage,
|
|
|
|
|
): void {
|
|
|
|
|
$userStatus = new UserStatus();
|
|
|
|
|
|
|
|
|
|
if ($expectExisting) {
|
|
|
|
|
@ -548,7 +508,7 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setCustomMessageDataProvider(): array {
|
|
|
|
|
public static function setCustomMessageDataProvider(): array {
|
|
|
|
|
return [
|
|
|
|
|
['john.doe', '😁', true, 'Custom message', null, true, true, false, null, null],
|
|
|
|
|
['john.doe', '😁', true, 'Custom message', null, false, true, false, null, null],
|
|
|
|
|
@ -815,7 +775,7 @@ class StatusServiceTest extends TestCase {
|
|
|
|
|
$this->service->revertMultipleUserStatus(['john', 'nobackup', 'backuponly', 'nobackupanddnd'], 'call');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function dataSetUserStatus(): array {
|
|
|
|
|
public static function dataSetUserStatus(): array {
|
|
|
|
|
return [
|
|
|
|
|
[IUserStatus::MESSAGE_CALENDAR_BUSY, '', false],
|
|
|
|
|
|
|
|
|
|
|