mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Merge pull request #12074 from nextcloud/techdebt/noid/clean-unit-tests
fix(tests): Clean up unit test code
This commit is contained in:
commit
a2bc199716
49 changed files with 795 additions and 1261 deletions
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -41,20 +43,13 @@ use Test\TestCase;
|
|||
* @package OCA\Talk\Tests\php\Activity
|
||||
*/
|
||||
class BaseTest extends TestCase {
|
||||
/** @var IFactory|MockObject */
|
||||
protected $l10nFactory;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
/** @var Config|MockObject */
|
||||
protected $config;
|
||||
/** @var IManager|MockObject */
|
||||
protected $activityManager;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
protected IFactory&MockObject $l10nFactory;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected Config&MockObject $config;
|
||||
protected IManager&MockObject $activityManager;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected Manager&MockObject $manager;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -104,7 +99,7 @@ class BaseTest extends TestCase {
|
|||
public function testPreParse(string $appId, bool $hasUser, bool $disabledForUser, bool $willThrowException): void {
|
||||
$user = $hasUser ? $this->createMock(IUser::class) : null;
|
||||
|
||||
/** @var IEvent|MockObject $event */
|
||||
/** @var IEvent&MockObject $event */
|
||||
$event = $this->createMock(IEvent::class);
|
||||
$event->expects($this->once())
|
||||
->method('getApp')
|
||||
|
|
@ -135,8 +130,8 @@ class BaseTest extends TestCase {
|
|||
static::invokePrivate($provider, 'preParse', [$event]);
|
||||
}
|
||||
|
||||
public function testPreParseThrows() {
|
||||
/** @var IEvent|MockObject $event */
|
||||
public function testPreParseThrows(): void {
|
||||
/** @var IEvent&MockObject $event */
|
||||
$event = $this->createMock(IEvent::class);
|
||||
$event->expects($this->once())
|
||||
->method('getApp')
|
||||
|
|
@ -146,7 +141,7 @@ class BaseTest extends TestCase {
|
|||
static::invokePrivate($provider, 'preParse', [$event]);
|
||||
}
|
||||
|
||||
public static function dataSetSubject() {
|
||||
public static function dataSetSubject(): array {
|
||||
return [
|
||||
['No placeholder', [], 'No placeholder'],
|
||||
['This has one {placeholder}', ['placeholder' => ['name' => 'foobar']], 'This has one foobar'],
|
||||
|
|
@ -156,12 +151,8 @@ class BaseTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSetSubject
|
||||
*
|
||||
* @param string $subject
|
||||
* @param array $parameters
|
||||
* @param string $parsedSubject
|
||||
*/
|
||||
public function testSetSubject($subject, array $parameters, $parsedSubject) {
|
||||
public function testSetSubject(string $subject, array $parameters, string $parsedSubject): void {
|
||||
$provider = $this->getProvider();
|
||||
|
||||
$event = $this->createMock(IEvent::class);
|
||||
|
|
@ -177,7 +168,7 @@ class BaseTest extends TestCase {
|
|||
self::invokePrivate($provider, 'setSubjects', [$event, $subject, $parameters]);
|
||||
}
|
||||
|
||||
public static function dataGetRoom() {
|
||||
public static function dataGetRoom(): array {
|
||||
return [
|
||||
[Room::TYPE_ONE_TO_ONE, 23, 'private-call', 'private-call', 'one2one'],
|
||||
[Room::TYPE_GROUP, 42, 'group-call', 'group-call', 'group'],
|
||||
|
|
@ -190,14 +181,8 @@ class BaseTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetRoom
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $expectedName
|
||||
* @param string $expectedType
|
||||
*/
|
||||
public function testGetRoom($type, $id, $name, $expectedName, $expectedType) {
|
||||
public function testGetRoom(int $type, int $id, string $name, string $expectedName, string $expectedType): void {
|
||||
$provider = $this->getProvider();
|
||||
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -239,10 +224,6 @@ class BaseTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetUser
|
||||
*
|
||||
* @param string $uid
|
||||
* @param bool $validUser
|
||||
* @param string $name
|
||||
*/
|
||||
public function testGetUser(string $uid, bool $validUser, string $name): void {
|
||||
$provider = $this->getProvider();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -43,20 +45,13 @@ use Test\TestCase;
|
|||
* @package OCA\Talk\Tests\php\Activity
|
||||
*/
|
||||
class InvitationTest extends TestCase {
|
||||
/** @var IFactory|MockObject */
|
||||
protected $l10nFactory;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
/** @var Config|MockObject */
|
||||
protected $config;
|
||||
/** @var IManager|MockObject */
|
||||
protected $activityManager;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
protected IFactory&MockObject $l10nFactory;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected Config&MockObject $config;
|
||||
protected IManager&MockObject $activityManager;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected Manager&MockObject $manager;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -100,8 +95,8 @@ class InvitationTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function testParseThrowsWrongSubject() {
|
||||
/** @var IEvent|MockObject $event */
|
||||
public function testParseThrowsWrongSubject(): void {
|
||||
/** @var IEvent&MockObject $event */
|
||||
$event = $this->createMock(IEvent::class);
|
||||
$event->expects($this->once())
|
||||
->method('getApp')
|
||||
|
|
@ -128,7 +123,7 @@ class InvitationTest extends TestCase {
|
|||
$provider->parse('en', $event);
|
||||
}
|
||||
|
||||
public static function dataParse() {
|
||||
public static function dataParse(): array {
|
||||
return [
|
||||
['en', true, ['room' => 23, 'user' => 'test1'], ['actor' => ['actor-data'], 'call' => ['call-data']]],
|
||||
['de', false, ['room' => 42, 'user' => 'test2'], ['actor' => ['actor-data'], 'call' => ['call-unknown']]],
|
||||
|
|
@ -137,16 +132,11 @@ class InvitationTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataParse
|
||||
*
|
||||
* @param string $lang
|
||||
* @param bool $roomExists
|
||||
* @param array $params
|
||||
* @param array $expectedParams
|
||||
*/
|
||||
public function testParse($lang, $roomExists, array $params, array $expectedParams) {
|
||||
public function testParse(string $lang, bool $roomExists, array $params, array $expectedParams): void {
|
||||
$provider = $this->getProvider(['setSubjects', 'getUser', 'getRoom', 'getFormerRoom']);
|
||||
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$l->expects($this->any())
|
||||
->method('t')
|
||||
|
|
@ -154,7 +144,7 @@ class InvitationTest extends TestCase {
|
|||
return vsprintf($text, $parameters);
|
||||
});
|
||||
|
||||
/** @var IEvent|MockObject $event */
|
||||
/** @var IEvent&MockObject $event */
|
||||
$event = $this->createMock(IEvent::class);
|
||||
$event->expects($this->once())
|
||||
->method('getApp')
|
||||
|
|
@ -180,7 +170,7 @@ class InvitationTest extends TestCase {
|
|||
->willReturn(false);
|
||||
|
||||
if ($roomExists) {
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$this->manager->expects($this->once())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -26,7 +28,7 @@ use OCP\Activity\ISetting;
|
|||
use Test\TestCase;
|
||||
|
||||
class SettingTest extends TestCase {
|
||||
public static function dataSettings() {
|
||||
public static function dataSettings(): array {
|
||||
return [
|
||||
[Setting::class],
|
||||
];
|
||||
|
|
@ -34,40 +36,36 @@ class SettingTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testImplementsInterface($settingClass) {
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
public function testImplementsInterface(string $settingClass): void {
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertInstanceOf(ISetting::class, $setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testGetIdentifier($settingClass) {
|
||||
public function testGetIdentifier(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsString($setting->getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testGetName($settingClass) {
|
||||
public function testGetName(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsString($setting->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testGetPriority($settingClass) {
|
||||
public function testGetPriority(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$priority = $setting->getPriority();
|
||||
$this->assertIsInt($setting->getPriority());
|
||||
$this->assertGreaterThanOrEqual(0, $priority);
|
||||
|
|
@ -76,41 +74,37 @@ class SettingTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testCanChangeStream($settingClass) {
|
||||
public function testCanChangeStream(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsBool($setting->canChangeStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testIsDefaultEnabledStream($settingClass) {
|
||||
public function testIsDefaultEnabledStream(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsBool($setting->isDefaultEnabledStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testCanChangeMail($settingClass) {
|
||||
public function testCanChangeMail(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsBool($setting->canChangeMail());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataSettings
|
||||
* @param string $settingClass
|
||||
*/
|
||||
public function testIsDefaultEnabledMail($settingClass) {
|
||||
public function testIsDefaultEnabledMail(string $settingClass): void {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OC::$server->get($settingClass);
|
||||
$setting = \OCP\Server::get($settingClass);
|
||||
$this->assertIsBool($setting->isDefaultEnabledMail());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,20 +39,13 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class CheckHostedSignalingServerTest extends TestCase {
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var HostedSignalingServerService|MockObject */
|
||||
protected $hostedSignalingServerService;
|
||||
/** @var IConfig|MockObject */
|
||||
protected $config;
|
||||
/** @var IManager|MockObject */
|
||||
protected $notificationManager;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $urlGenerator;
|
||||
/** @var LoggerInterface|MockObject */
|
||||
protected $logger;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected HostedSignalingServerService&MockObject $hostedSignalingServerService;
|
||||
protected IConfig&MockObject $config;
|
||||
protected IManager&MockObject $notificationManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected IURLGenerator&MockObject $urlGenerator;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -78,7 +71,7 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function testRunWithNoChange() {
|
||||
public function testRunWithNoChange(): void {
|
||||
$backgroundJob = $this->getBackgroundJob();
|
||||
|
||||
$this->config
|
||||
|
|
@ -92,10 +85,10 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||
->method('fetchAccountInfo')
|
||||
->willReturn(['status' => 'pending']);
|
||||
|
||||
$this->invokePrivate($backgroundJob, 'run', ['']);
|
||||
self::invokePrivate($backgroundJob, 'run', ['']);
|
||||
}
|
||||
|
||||
public function testRunWithPendingToActiveChange() {
|
||||
public function testRunWithPendingToActiveChange(): void {
|
||||
$backgroundJob = $this->getBackgroundJob();
|
||||
$newStatus = [
|
||||
'status' => 'active',
|
||||
|
|
@ -142,6 +135,6 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||
->method('fetchAccountInfo')
|
||||
->willReturn($newStatus);
|
||||
|
||||
$this->invokePrivate($backgroundJob, 'run', ['']);
|
||||
self::invokePrivate($backgroundJob, 'run', ['']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,24 +33,18 @@ use OCA\Talk\Service\ParticipantService;
|
|||
use OCA\Talk\Service\RoomService;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Files\Config\IUserMountCache;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class RemoveEmptyRoomsTest extends TestCase {
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var RoomService|MockObject */
|
||||
protected $roomService;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $federationManager;
|
||||
/** @var LoggerInterface|MockObject */
|
||||
protected $loggerInterface;
|
||||
/** @var IUserMountCache|MockObject */
|
||||
protected $userMountCache;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected Manager&MockObject $manager;
|
||||
protected RoomService&MockObject $roomService;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected FederationManager&MockObject $federationManager;
|
||||
protected LoggerInterface&MockObject $loggerInterface;
|
||||
protected IUserMountCache&MockObject $userMountCache;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -91,6 +85,15 @@ class RemoveEmptyRoomsTest extends TestCase {
|
|||
$this->assertEquals(1, $numDeletedRooms, 'Invalid final quantity of rooms');
|
||||
}
|
||||
|
||||
public static function dataDeleteIfFileIsRemoved(): array {
|
||||
return [
|
||||
['', [], 0],
|
||||
['email', [], 0],
|
||||
['file', ['fileExists'], 0],
|
||||
['file', [], 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataDeleteIfFileIsRemoved
|
||||
*/
|
||||
|
|
@ -116,12 +119,14 @@ class RemoveEmptyRoomsTest extends TestCase {
|
|||
$this->assertEquals($numDeletedRoomsExpected, $numDeletedRoomsActual, 'Invalid final quantity of rooms');
|
||||
}
|
||||
|
||||
public static function dataDeleteIfFileIsRemoved(): array {
|
||||
public static function dataDeleteIfIsEmpty(): array {
|
||||
return [
|
||||
['', [], 0],
|
||||
['email', [], 0],
|
||||
['file', ['fileExists'], 0],
|
||||
['file', [], 1],
|
||||
'room with user' => ['', 1, 0, 0],
|
||||
'room with fed invite' => ['', 0, 1, 0],
|
||||
'room to delete' => ['', 0, 0, 1],
|
||||
'file room with user' => ['file', 1, 0, 0],
|
||||
'email room with user' => ['email', 1, 0, 0],
|
||||
'email room without user' => ['email', 0, 0, 1]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -156,17 +161,6 @@ class RemoveEmptyRoomsTest extends TestCase {
|
|||
$this->assertEquals($numDeletedRoomsExpected, $numDeletedRoomsActual, 'Invalid final quantity of rooms');
|
||||
}
|
||||
|
||||
public static function dataDeleteIfIsEmpty(): array {
|
||||
return [
|
||||
'room with user' => ['', 1, 0, 0],
|
||||
'room with fed invite' => ['', 0, 1, 0],
|
||||
'room to delete' => ['', 0, 0, 1],
|
||||
'file room with user' => ['file', 1, 0, 0],
|
||||
'email room with user' => ['email', 1, 0, 0],
|
||||
'email room without user' => ['email', 0, 0, 1]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataCallback
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,15 +43,15 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class CapabilitiesTest extends TestCase {
|
||||
protected IConfig|MockObject $serverConfig;
|
||||
protected Config|MockObject $talkConfig;
|
||||
protected IAppConfig|MockObject $appConfig;
|
||||
protected CommentsManager|MockObject $commentsManager;
|
||||
protected IUserSession|MockObject $userSession;
|
||||
protected IAppManager|MockObject $appManager;
|
||||
protected ITranslationManager|MockObject $translationManager;
|
||||
protected ICacheFactory|MockObject $cacheFactory;
|
||||
protected ICache|MockObject $talkCache;
|
||||
protected IConfig&MockObject $serverConfig;
|
||||
protected Config&MockObject $talkConfig;
|
||||
protected IAppConfig&MockObject $appConfig;
|
||||
protected CommentsManager&MockObject $commentsManager;
|
||||
protected IUserSession&MockObject $userSession;
|
||||
protected IAppManager&MockObject $appManager;
|
||||
protected ITranslationManager&MockObject $translationManager;
|
||||
protected ICacheFactory&MockObject $cacheFactory;
|
||||
protected ICache&MockObject $talkCache;
|
||||
protected ?array $baseFeatures = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -256,11 +256,6 @@ class CapabilitiesTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetCapabilitiesUserAllowed
|
||||
* @param bool $isNotAllowed
|
||||
* @param bool $canCreate
|
||||
* @param string $quota
|
||||
* @param bool $canUpload
|
||||
* @param int $readPrivacy
|
||||
*/
|
||||
public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCreate, string $quota, bool $canUpload, int $readPrivacy): void {
|
||||
$capabilities = new Capabilities(
|
||||
|
|
@ -442,6 +437,13 @@ class CapabilitiesTest extends TestCase {
|
|||
$this->assertEquals('this-is-the-key', $data['spreed']['config']['signaling']['hello-v2-token-key']);
|
||||
}
|
||||
|
||||
public static function dataTestConfigRecording(): array {
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestConfigRecording
|
||||
*/
|
||||
|
|
@ -465,13 +467,6 @@ class CapabilitiesTest extends TestCase {
|
|||
$this->assertEquals($data['spreed']['config']['call']['recording'], $enabled);
|
||||
}
|
||||
|
||||
public static function dataTestConfigRecording(): array {
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testCapabilitiesTranslations(): void {
|
||||
$capabilities = new Capabilities(
|
||||
$this->serverConfig,
|
||||
|
|
|
|||
|
|
@ -42,19 +42,13 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class SearchPluginTest extends TestCase {
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var GuestManager|MockObject */
|
||||
protected $guestManager;
|
||||
/** @var TalkSession|MockObject */
|
||||
protected $talkSession;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var Util|MockObject */
|
||||
protected $util;
|
||||
protected Authenticator|MockObject $federationAuthenticator;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected GuestManager&MockObject $guestManager;
|
||||
protected TalkSession&MockObject $talkSession;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected Util&MockObject $util;
|
||||
protected Authenticator&MockObject $federationAuthenticator;
|
||||
protected IL10N&MockObject $l;
|
||||
protected ?string $userId = null;
|
||||
protected SearchPlugin $plugin;
|
||||
|
||||
|
|
@ -110,7 +104,7 @@ class SearchPluginTest extends TestCase {
|
|||
}
|
||||
|
||||
protected function createParticipantMock(string $uid, string $displayName, string $session = ''): Participant {
|
||||
/** @var Participant|MockObject $p */
|
||||
/** @var Participant&MockObject $p */
|
||||
$p = $this->createMock(Participant::class);
|
||||
$a = Attendee::fromRow([
|
||||
'actor_type' => $uid ? 'users' : 'guests',
|
||||
|
|
@ -134,7 +128,7 @@ class SearchPluginTest extends TestCase {
|
|||
return $p;
|
||||
}
|
||||
|
||||
public function testSearch() {
|
||||
public function testSearch(): void {
|
||||
$result = $this->createMock(ISearchResult::class);
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
|
|
@ -221,13 +215,8 @@ class SearchPluginTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSearchGuests
|
||||
* @param string $search
|
||||
* @param string[] $sessionHashes
|
||||
* @param array $displayNames
|
||||
* @param array $expected
|
||||
* @param array $expectedExact
|
||||
*/
|
||||
public function testSearchGuests($search, array $guests, array $expected, array $expectedExact): void {
|
||||
public function testSearchGuests(string $search, array $guests, array $expected, array $expectedExact): void {
|
||||
$result = $this->createMock(ISearchResult::class);
|
||||
$result->expects($this->once())
|
||||
->method('addResultSet')
|
||||
|
|
@ -262,7 +251,7 @@ class SearchPluginTest extends TestCase {
|
|||
return $user;
|
||||
}
|
||||
|
||||
public static function dataCreateResult() {
|
||||
public static function dataCreateResult(): array {
|
||||
return [
|
||||
['user', 'foo', 'bar', '', ['label' => 'bar', 'value' => ['shareType' => 'user', 'shareWith' => 'foo']]],
|
||||
['user', 'test', 'Test', '', ['label' => 'Test', 'value' => ['shareType' => 'user', 'shareWith' => 'test']]],
|
||||
|
|
@ -273,13 +262,8 @@ class SearchPluginTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateResult
|
||||
* @param string $type
|
||||
* @param string $uid
|
||||
* @param string $name
|
||||
* @param string $managerName
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testCreateResult($type, $uid, $name, $managerName, array $expected) {
|
||||
public function testCreateResult(string $type, string $uid, string $name, ?string $managerName, array $expected): void {
|
||||
if ($managerName !== null) {
|
||||
$this->userManager->expects($this->any())
|
||||
->method('getDisplayName')
|
||||
|
|
@ -306,9 +290,6 @@ class SearchPluginTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateGuestResult
|
||||
* @param string $actorId
|
||||
* @param string $name
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testCreateGuestResult(string $actorId, string $name, array $expected): void {
|
||||
$plugin = $this->getPlugin();
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class SorterTest extends TestCase {
|
||||
/** @var CommentsManager|MockObject */
|
||||
protected $commentsManager;
|
||||
protected CommentsManager&MockObject $commentsManager;
|
||||
|
||||
protected string $userId;
|
||||
|
||||
|
|
@ -67,7 +66,7 @@ class SorterTest extends TestCase {
|
|||
$this->sorter = new Sorter($this->commentsManager);
|
||||
}
|
||||
|
||||
public function testGetId() {
|
||||
public function testGetId(): void {
|
||||
$this->assertSame('talk_chat_participants', $this->sorter->getId());
|
||||
}
|
||||
|
||||
|
|
@ -85,13 +84,8 @@ class SorterTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSort
|
||||
*
|
||||
* @param string $search
|
||||
* @param array $toSort
|
||||
* @param array $comments
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testSort(string $search, array $toSort, array $comments, array $expected) {
|
||||
public function testSort(string $search, array $toSort, array $comments, array $expected): void {
|
||||
$this->commentsManager->expects(isset($toSort['users']) ? $this->once() : $this->never())
|
||||
->method('getLastCommentDateByActor')
|
||||
->with('chat', '23', 'comment', 'users', $this->anything())
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ use OCP\Comments\IComment;
|
|||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
|
|
@ -58,35 +59,21 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class ChatManagerTest extends TestCase {
|
||||
/** @var CommentsManager|ICommentsManager|MockObject */
|
||||
protected $commentsManager;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $dispatcher;
|
||||
/** @var INotificationManager|MockObject */
|
||||
protected $notificationManager;
|
||||
/** @var IManager|MockObject */
|
||||
protected $shareManager;
|
||||
/** @var RoomShareProvider|MockObject */
|
||||
protected $shareProvider;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var RoomService|MockObject */
|
||||
protected $roomService;
|
||||
/** @var PollService|MockObject */
|
||||
protected $pollService;
|
||||
/** @var Notifier|MockObject */
|
||||
protected $notifier;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var AttachmentService|MockObject */
|
||||
protected $attachmentService;
|
||||
/** @var IReferenceManager|MockObject */
|
||||
protected $referenceManager;
|
||||
/** @var ILimiter|MockObject */
|
||||
protected $rateLimiter;
|
||||
/** @var IRequest|MockObject */
|
||||
protected $request;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
protected CommentsManager|ICommentsManager|MockObject $commentsManager;
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected INotificationManager&MockObject $notificationManager;
|
||||
protected IManager&MockObject $shareManager;
|
||||
protected RoomShareProvider&MockObject $shareProvider;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected RoomService&MockObject $roomService;
|
||||
protected PollService&MockObject $pollService;
|
||||
protected Notifier&MockObject $notifier;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected AttachmentService&MockObject $attachmentService;
|
||||
protected IReferenceManager&MockObject $referenceManager;
|
||||
protected ILimiter&MockObject $rateLimiter;
|
||||
protected IRequest&MockObject $request;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected ?ChatManager $chatManager = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -123,7 +110,7 @@ class ChatManagerTest extends TestCase {
|
|||
->setConstructorArgs([
|
||||
$this->commentsManager,
|
||||
$this->dispatcher,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
$this->notificationManager,
|
||||
$this->shareManager,
|
||||
$this->shareProvider,
|
||||
|
|
@ -146,7 +133,7 @@ class ChatManagerTest extends TestCase {
|
|||
return new ChatManager(
|
||||
$this->commentsManager,
|
||||
$this->dispatcher,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
$this->notificationManager,
|
||||
$this->shareManager,
|
||||
$this->shareProvider,
|
||||
|
|
@ -223,10 +210,6 @@ class ChatManagerTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSendMessage
|
||||
* @param string $userId
|
||||
* @param string $message
|
||||
* @param string $referenceId
|
||||
* @param string $parentId
|
||||
*/
|
||||
public function testSendMessage(string $userId, string $message, string $referenceId, string $parentId): void {
|
||||
$creationDateTime = new \DateTime();
|
||||
|
|
@ -343,7 +326,7 @@ class ChatManagerTest extends TestCase {
|
|||
->method('markMentionNotificationsRead')
|
||||
->with($chat, 'userId');
|
||||
|
||||
/** @var IUser|MockObject $user */
|
||||
/** @var IUser&MockObject $user */
|
||||
$user = $this->createMock(IUser::class);
|
||||
$user->expects($this->any())
|
||||
->method('getUID')
|
||||
|
|
@ -381,7 +364,7 @@ class ChatManagerTest extends TestCase {
|
|||
->method('markMentionNotificationsRead')
|
||||
->with($chat, 'userId');
|
||||
|
||||
/** @var IUser|MockObject $user */
|
||||
/** @var IUser&MockObject $user */
|
||||
$user = $this->createMock(IUser::class);
|
||||
$user->expects($this->any())
|
||||
->method('getUID')
|
||||
|
|
@ -393,7 +376,7 @@ class ChatManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetUnreadCount(): void {
|
||||
/** @var Room|MockObject $chat */
|
||||
/** @var Room&MockObject $chat */
|
||||
$chat = $this->createMock(Room::class);
|
||||
$chat->expects($this->atLeastOnce())
|
||||
->method('getId')
|
||||
|
|
@ -424,7 +407,7 @@ class ChatManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteMessage(): void {
|
||||
$mapper = new AttendeeMapper(\OC::$server->getDatabaseConnection());
|
||||
$mapper = new AttendeeMapper(\OCP\Server::get(IDBConnection::class));
|
||||
$attendee = $mapper->createAttendeeFromRow([
|
||||
'a_id' => 1,
|
||||
'room_id' => 123,
|
||||
|
|
@ -485,7 +468,7 @@ class ChatManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteMessageFileShare(): void {
|
||||
$mapper = new AttendeeMapper(\OC::$server->getDatabaseConnection());
|
||||
$mapper = new AttendeeMapper(\OCP\Server::get(IDBConnection::class));
|
||||
$attendee = $mapper->createAttendeeFromRow([
|
||||
'a_id' => 1,
|
||||
'room_id' => 123,
|
||||
|
|
@ -568,7 +551,7 @@ class ChatManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteMessageFileShareNotFound(): void {
|
||||
$mapper = new AttendeeMapper(\OC::$server->getDatabaseConnection());
|
||||
$mapper = new AttendeeMapper(\OCP\Server::get(IDBConnection::class));
|
||||
$attendee = $mapper->createAttendeeFromRow([
|
||||
'a_id' => 1,
|
||||
'room_id' => 123,
|
||||
|
|
@ -755,7 +738,7 @@ class ChatManagerTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider dataAddConversationNotify
|
||||
*/
|
||||
public function testAddConversationNotify($search, $roomMocks, $participantMocks, $expected) {
|
||||
public function testAddConversationNotify(string $search, array$roomMocks, array $participantMocks, array $expected): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
foreach ($roomMocks as $method => $return) {
|
||||
$room->expects($this->once())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -37,21 +38,11 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class ExecutorTest extends TestCase {
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $dispatcher;
|
||||
|
||||
/** @var ShellExecutor|MockObject */
|
||||
protected $shellExecutor;
|
||||
|
||||
/** @var CommandService|MockObject */
|
||||
protected $commandService;
|
||||
|
||||
/** @var LoggerInterface|MockObject */
|
||||
protected $logger;
|
||||
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l10n;
|
||||
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected ShellExecutor&MockObject $shellExecutor;
|
||||
protected CommandService&MockObject $commandService;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected IL10N&MockObject $l10n;
|
||||
protected ?Executor $executor = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -80,8 +71,6 @@ class ExecutorTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataExecApp
|
||||
* @param string $arguments
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testExecApp(string $arguments, string $expected): void {
|
||||
$message = $this->createMock(IComment::class);
|
||||
|
|
@ -125,14 +114,9 @@ class ExecutorTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataExecShell
|
||||
* @param string|null $actorId
|
||||
* @param string $roomToken
|
||||
* @param string $script
|
||||
* @param string $arguments
|
||||
* @param string $output
|
||||
*/
|
||||
public function testExecShell(?string $actorId, string $roomToken, string $script, string $arguments, string $output): void {
|
||||
/** @var IComment|MockObject $message */
|
||||
/** @var IComment&MockObject $message */
|
||||
$message = $this->createMock(IComment::class);
|
||||
if ($actorId === null) {
|
||||
$message->expects($this->once())
|
||||
|
|
@ -149,7 +133,7 @@ class ExecutorTest extends TestCase {
|
|||
->willReturn($actorId);
|
||||
}
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->expects($this->once())
|
||||
->method('getToken')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -61,11 +62,6 @@ class ShellExecutorTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataExecShellRun
|
||||
* @param string|null $actorId
|
||||
* @param string $roomToken
|
||||
* @param string $cmd
|
||||
* @param string $arguments
|
||||
* @param string $output
|
||||
*/
|
||||
public function testExecShellRun(?string $actorId, string $roomToken, string $cmd, string $arguments, string $output): void {
|
||||
$executor = new ShellExecutor();
|
||||
|
|
@ -82,12 +78,6 @@ class ShellExecutorTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataExecShell
|
||||
* @param string|null $actorId
|
||||
* @param string $roomToken
|
||||
* @param string $cmd
|
||||
* @param string $arguments
|
||||
* @param string $expected
|
||||
* @param string $output
|
||||
*/
|
||||
public function testExecShell(?string $actorId, string $roomToken, string $cmd, string $arguments, string $expected, string $output): void {
|
||||
$executor = $this->getMockBuilder(ShellExecutor::class)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -43,20 +44,13 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class NotifierTest extends TestCase {
|
||||
/** @var INotificationManager|MockObject */
|
||||
protected $notificationManager;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var IConfig|MockObject */
|
||||
protected $config;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var Util|MockObject */
|
||||
protected $util;
|
||||
protected INotificationManager&MockObject $notificationManager;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected IConfig&MockObject $config;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected Util&MockObject $util;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -149,23 +143,6 @@ class NotifierTest extends TestCase {
|
|||
return $room;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataNotifyMentionedUsers
|
||||
*/
|
||||
public function testNotifyMentionedUsers(string $message, array $alreadyNotifiedUsers, array $notify, array $expectedReturn): void {
|
||||
if (count($notify)) {
|
||||
$this->notificationManager->expects($this->exactly(count($notify)))
|
||||
->method('notify');
|
||||
}
|
||||
|
||||
$room = $this->getRoom();
|
||||
$comment = $this->newComment('108', 'users', 'testUser', new \DateTime('@' . 1000000016), $message);
|
||||
$notifier = $this->getNotifier([]);
|
||||
$actual = $notifier->notifyMentionedUsers($room, $comment, $alreadyNotifiedUsers, false);
|
||||
|
||||
$this->assertEqualsCanonicalizing($expectedReturn, $actual);
|
||||
}
|
||||
|
||||
public static function dataNotifyMentionedUsers(): array {
|
||||
return [
|
||||
'no notifications' => [
|
||||
|
|
@ -203,6 +180,23 @@ class NotifierTest extends TestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataNotifyMentionedUsers
|
||||
*/
|
||||
public function testNotifyMentionedUsers(string $message, array $alreadyNotifiedUsers, array $notify, array $expectedReturn): void {
|
||||
if (count($notify)) {
|
||||
$this->notificationManager->expects($this->exactly(count($notify)))
|
||||
->method('notify');
|
||||
}
|
||||
|
||||
$room = $this->getRoom();
|
||||
$comment = $this->newComment('108', 'users', 'testUser', new \DateTime('@' . 1000000016), $message);
|
||||
$notifier = $this->getNotifier([]);
|
||||
$actual = $notifier->notifyMentionedUsers($room, $comment, $alreadyNotifiedUsers, false);
|
||||
|
||||
$this->assertEqualsCanonicalizing($expectedReturn, $actual);
|
||||
}
|
||||
|
||||
public static function dataShouldParticipantBeNotified(): array {
|
||||
return [
|
||||
[Attendee::ACTOR_GROUPS, 'test1', null, Attendee::ACTOR_USERS, 'test1', [], false],
|
||||
|
|
@ -217,13 +211,6 @@ class NotifierTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataShouldParticipantBeNotified
|
||||
* @param string $actorType
|
||||
* @param string $actorId
|
||||
* @param int|null $sessionAge
|
||||
* @param string $commentActorType
|
||||
* @param string $commentActorId
|
||||
* @param array $alreadyNotifiedUsers
|
||||
* @param bool $expected
|
||||
*/
|
||||
public function testShouldParticipantBeNotified(string $actorType, string $actorId, ?int $sessionAge, string $commentActorType, string $commentActorId, array $alreadyNotifiedUsers, bool $expected): void {
|
||||
$comment = $this->createMock(IComment::class);
|
||||
|
|
@ -310,27 +297,6 @@ class NotifierTest extends TestCase {
|
|||
$this->getNotifier()->removePendingNotificationsForRoom($room, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataAddMentionAllToList
|
||||
*/
|
||||
public function testAddMentionAllToList(array $usersToNotify, array $participants, array $return): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
$this->participantService
|
||||
->method('getActorsByType')
|
||||
->willReturn($participants);
|
||||
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'addMentionAllToList', [$room, $usersToNotify]);
|
||||
$this->assertCount(count($return), $actual);
|
||||
foreach ($actual as $key => $value) {
|
||||
$this->assertIsArray($value);
|
||||
if (array_key_exists('attendee', $value)) {
|
||||
$this->assertInstanceOf(Attendee::class, $value['attendee']);
|
||||
unset($value['attendee']);
|
||||
}
|
||||
$this->assertEqualsCanonicalizing($return[$key], $value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function dataAddMentionAllToList(): array {
|
||||
return [
|
||||
'not notify' => [
|
||||
|
|
@ -364,6 +330,42 @@ class NotifierTest extends TestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataAddMentionAllToList
|
||||
*/
|
||||
public function testAddMentionAllToList(array $usersToNotify, array $participants, array $return): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
$this->participantService
|
||||
->method('getActorsByType')
|
||||
->willReturn($participants);
|
||||
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'addMentionAllToList', [$room, $usersToNotify]);
|
||||
$this->assertCount(count($return), $actual);
|
||||
foreach ($actual as $key => $value) {
|
||||
$this->assertIsArray($value);
|
||||
if (array_key_exists('attendee', $value)) {
|
||||
$this->assertInstanceOf(Attendee::class, $value['attendee']);
|
||||
unset($value['attendee']);
|
||||
}
|
||||
$this->assertEqualsCanonicalizing($return[$key], $value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function dataNotifyReacted(): array {
|
||||
return [
|
||||
'author react to own message' =>
|
||||
[0, Participant::NOTIFY_MENTION, Room::TYPE_GROUP, 'testUser'],
|
||||
'notify never' =>
|
||||
[0, Participant::NOTIFY_NEVER, Room::TYPE_GROUP, 'testUser2'],
|
||||
'notify default, not one to one' =>
|
||||
[0, Participant::NOTIFY_DEFAULT, Room::TYPE_GROUP, 'testUser2'],
|
||||
'notify default, one to one' =>
|
||||
[1, Participant::NOTIFY_DEFAULT, Room::TYPE_ONE_TO_ONE, 'testUser2'],
|
||||
'notify always' =>
|
||||
[1, Participant::NOTIFY_ALWAYS, Room::TYPE_GROUP, 'testUser2'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataNotifyReacted
|
||||
*/
|
||||
|
|
@ -387,30 +389,6 @@ class NotifierTest extends TestCase {
|
|||
$notifier->notifyReacted($room, $comment, $reaction);
|
||||
}
|
||||
|
||||
public static function dataNotifyReacted(): array {
|
||||
return [
|
||||
'author react to own message' =>
|
||||
[0, Participant::NOTIFY_MENTION, Room::TYPE_GROUP, 'testUser'],
|
||||
'notify never' =>
|
||||
[0, Participant::NOTIFY_NEVER, Room::TYPE_GROUP, 'testUser2'],
|
||||
'notify default, not one to one' =>
|
||||
[0, Participant::NOTIFY_DEFAULT, Room::TYPE_GROUP, 'testUser2'],
|
||||
'notify default, one to one' =>
|
||||
[1, Participant::NOTIFY_DEFAULT, Room::TYPE_ONE_TO_ONE, 'testUser2'],
|
||||
'notify always' =>
|
||||
[1, Participant::NOTIFY_ALWAYS, Room::TYPE_GROUP, 'testUser2'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetMentionedUsers
|
||||
*/
|
||||
public function testGetMentionedUsers(string $message, array $expectedReturn): void {
|
||||
$comment = $this->newComment('108', 'users', 'testUser', new \DateTime('@' . 1000000016), $message);
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'getMentionedUsers', [$comment]);
|
||||
$this->assertEqualsCanonicalizing($expectedReturn, $actual);
|
||||
}
|
||||
|
||||
public static function dataGetMentionedUsers(): array {
|
||||
return [
|
||||
'mention one user' => [
|
||||
|
|
@ -443,11 +421,11 @@ class NotifierTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetMentionedUserIds
|
||||
* @dataProvider dataGetMentionedUsers
|
||||
*/
|
||||
public function testGetMentionedUserIds(string $message, array $expectedReturn): void {
|
||||
public function testGetMentionedUsers(string $message, array $expectedReturn): void {
|
||||
$comment = $this->newComment('108', 'users', 'testUser', new \DateTime('@' . 1000000016), $message);
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'getMentionedUserIds', [$comment]);
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'getMentionedUsers', [$comment]);
|
||||
$this->assertEqualsCanonicalizing($expectedReturn, $actual);
|
||||
}
|
||||
|
||||
|
|
@ -461,4 +439,13 @@ class NotifierTest extends TestCase {
|
|||
});
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetMentionedUserIds
|
||||
*/
|
||||
public function testGetMentionedUserIds(string $message, array $expectedReturn): void {
|
||||
$comment = $this->newComment('108', 'users', 'testUser', new \DateTime('@' . 1000000016), $message);
|
||||
$actual = self::invokePrivate($this->getNotifier(), 'getMentionedUserIds', [$comment]);
|
||||
$this->assertEqualsCanonicalizing($expectedReturn, $actual);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -57,31 +59,19 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class SystemMessageTest extends TestCase {
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var GuestManager|MockObject */
|
||||
protected $guestManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var IPreviewManager|MockObject */
|
||||
protected $previewManager;
|
||||
/** @var RoomShareProvider|MockObject */
|
||||
protected $shareProvider;
|
||||
/** @var PhotoCache|MockObject */
|
||||
protected $photoCache;
|
||||
/** @var IRootFolder|MockObject */
|
||||
protected $rootFolder;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
/** @var ICloudIdManager|MockObject */
|
||||
protected $cloudIdManager;
|
||||
/** @var FilesMetadataCache|MockObject */
|
||||
protected $filesMetadataCache;
|
||||
protected Authenticator|MockObject $federationAuthenticator;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected GuestManager&MockObject $guestManager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected IPreviewManager&MockObject $previewManager;
|
||||
protected RoomShareProvider&MockObject $shareProvider;
|
||||
protected PhotoCache&MockObject $photoCache;
|
||||
protected IRootFolder&MockObject $rootFolder;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected ICloudIdManager&MockObject $cloudIdManager;
|
||||
protected FilesMetadataCache&MockObject $filesMetadataCache;
|
||||
protected Authenticator&MockObject $federationAuthenticator;
|
||||
protected IL10N&MockObject $l;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -104,9 +94,9 @@ class SystemMessageTest extends TestCase {
|
|||
return vsprintf($text, $parameters);
|
||||
});
|
||||
$this->l->method('n')
|
||||
->willReturnCallback(function ($singular, $plural, $count, $parameters = []) {
|
||||
->willReturnCallback(function (string $singular, string $plural, int $count, array $parameters = []) {
|
||||
$text = $count === 1 ? $singular : $plural;
|
||||
return vsprintf(str_replace('%n', $count, $text), $parameters);
|
||||
return vsprintf(str_replace('%n', (string) $count, $text), $parameters);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -461,14 +451,9 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataParseMessage
|
||||
* @param string $message
|
||||
* @param array $parameters
|
||||
* @param string|null $recipientId
|
||||
* @param string $expectedMessage
|
||||
* @param array $expectedParameters
|
||||
*/
|
||||
public function testParseMessage(string $message, array $parameters, ?string $recipientId, string $expectedMessage, array $expectedParameters) {
|
||||
/** @var Participant|MockObject $participant */
|
||||
public function testParseMessage(string $message, array $parameters, ?string $recipientId, string $expectedMessage, array $expectedParameters): void {
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
if ($recipientId === null) {
|
||||
$participant = null;
|
||||
|
|
@ -506,7 +491,7 @@ class SystemMessageTest extends TestCase {
|
|||
->willReturn($session);
|
||||
}
|
||||
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->createMock(IComment::class);
|
||||
if ($recipientId && strpos($recipientId, 'guest::') !== false) {
|
||||
$comment->method('getActorType')
|
||||
|
|
@ -520,7 +505,7 @@ class SystemMessageTest extends TestCase {
|
|||
->willReturn($recipientId);
|
||||
}
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$parser = $this->getParser(['getActorFromComment', 'getUser', 'getGroup', 'getGuest', 'parseCall', 'getFileFromShare']);
|
||||
|
|
@ -594,13 +579,12 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataParseMessageThrows
|
||||
* @param string|null $return
|
||||
*/
|
||||
public function testParseMessageThrows($return) {
|
||||
/** @var IComment|MockObject $comment */
|
||||
public function testParseMessageThrows(?string $return): void {
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->createMock(IComment::class);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$parser = $this->getParser(['getActorFromComment']);
|
||||
|
|
@ -609,7 +593,7 @@ class SystemMessageTest extends TestCase {
|
|||
->with($room, $comment)
|
||||
->willReturn(['id' => 'actor', 'type' => 'user']);
|
||||
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $this->l);
|
||||
$chatMessage->setMessage($return, []);
|
||||
|
|
@ -618,7 +602,7 @@ class SystemMessageTest extends TestCase {
|
|||
self::invokePrivate($parser, 'parseMessage', [$chatMessage]);
|
||||
}
|
||||
|
||||
public function testGetFileFromShareForGuest() {
|
||||
public function testGetFileFromShareForGuest(): void {
|
||||
$node = $this->createMock(Node::class);
|
||||
$node->expects($this->once())
|
||||
->method('getId')
|
||||
|
|
@ -691,7 +675,7 @@ class SystemMessageTest extends TestCase {
|
|||
], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));
|
||||
}
|
||||
|
||||
public function testGetFileFromShareForOwner() {
|
||||
public function testGetFileFromShareForOwner(): void {
|
||||
$node = $this->createMock(Node::class);
|
||||
$node->expects($this->exactly(2))
|
||||
->method('getId')
|
||||
|
|
@ -770,7 +754,7 @@ class SystemMessageTest extends TestCase {
|
|||
], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));
|
||||
}
|
||||
|
||||
public function testGetFileFromShareForRecipient() {
|
||||
public function testGetFileFromShareForRecipient(): void {
|
||||
$share = $this->createMock(IShare::class);
|
||||
$share->expects($this->any())
|
||||
->method('getNodeId')
|
||||
|
|
@ -857,7 +841,7 @@ class SystemMessageTest extends TestCase {
|
|||
], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));
|
||||
}
|
||||
|
||||
public function testGetFileFromShareForRecipientThrows() {
|
||||
public function testGetFileFromShareForRecipientThrows(): void {
|
||||
$share = $this->createMock(IShare::class);
|
||||
$share->expects($this->any())
|
||||
->method('getNodeId')
|
||||
|
|
@ -899,7 +883,7 @@ class SystemMessageTest extends TestCase {
|
|||
self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']);
|
||||
}
|
||||
|
||||
public function testGetFileFromShareThrows() {
|
||||
public function testGetFileFromShareThrows(): void {
|
||||
$this->shareProvider->expects($this->once())
|
||||
->method('getShareById')
|
||||
->with('23')
|
||||
|
|
@ -920,13 +904,9 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetActor
|
||||
* @param string $actorType
|
||||
* @param array $guestData
|
||||
* @param array $userData
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testGetActor(string $actorType, array $guestData, array $userData, array $expected) {
|
||||
/** @var Room|MockObject $room */
|
||||
public function testGetActor(string $actorType, array $guestData, array $userData, array $expected): void {
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$chatMessage = $this->createMock(IComment::class);
|
||||
|
|
@ -971,12 +951,8 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetUser
|
||||
* @param string $uid
|
||||
* @param array $cache
|
||||
* @param bool $cacheHit
|
||||
* @param string $name
|
||||
*/
|
||||
public function testGetUser(string $uid, array $cache, bool $cacheHit, string $name) {
|
||||
public function testGetUser(string $uid, array $cache, bool $cacheHit, string $name): void {
|
||||
$parser = $this->getParser(['getDisplayName']);
|
||||
|
||||
self::invokePrivate($parser, 'displayNames', [$cache]);
|
||||
|
|
@ -1006,11 +982,8 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetDisplayName
|
||||
* @param string $uid
|
||||
* @param bool $validUser
|
||||
* @param string $name
|
||||
*/
|
||||
public function testGetDisplayName(string $uid, bool $validUser, string $name) {
|
||||
public function testGetDisplayName(string $uid, bool $validUser, string $name): void {
|
||||
$parser = $this->getParser();
|
||||
|
||||
if ($validUser) {
|
||||
|
|
@ -1039,10 +1012,6 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetGroup
|
||||
* @param string $gid
|
||||
* @param array $cache
|
||||
* @param bool $cacheHit
|
||||
* @param string $name
|
||||
*/
|
||||
public function testGetGroup(string $gid, array $cache, bool $cacheHit, string $name): void {
|
||||
$parser = $this->getParser(['getDisplayNameGroup']);
|
||||
|
|
@ -1074,9 +1043,6 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetDisplayNameGroup
|
||||
* @param string $gid
|
||||
* @param bool $validGroup
|
||||
* @param string $name
|
||||
*/
|
||||
public function testGetDisplayNameGroup(string $gid, bool $validGroup, string $name): void {
|
||||
$parser = $this->getParser();
|
||||
|
|
@ -1109,11 +1075,9 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetGuest
|
||||
* @param string $attendeeType
|
||||
* @param string $actorId
|
||||
*/
|
||||
public function testGetGuest(string $attendeeType, string $actorId): void {
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$parser = $this->getParser(['getGuestName']);
|
||||
|
|
@ -1147,20 +1111,16 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetGuestName
|
||||
* @param string $actorType
|
||||
* @param string $actorId
|
||||
* @param string $attendeeName
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testGetGuestName(string $actorType, string $actorId, string $attendeeName, string $expected): void {
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$attendee = Attendee::fromParams([
|
||||
'displayName' => $attendeeName,
|
||||
]);
|
||||
|
||||
/** @var Participant|MockObject $room */
|
||||
/** @var Participant&MockObject $room */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$participant->method('getAttendee')
|
||||
->willReturn($attendee);
|
||||
|
|
@ -1174,10 +1134,10 @@ class SystemMessageTest extends TestCase {
|
|||
$this->assertSame($expected, self::invokePrivate($parser, 'getGuestName', [$room, $actorType, $actorId]));
|
||||
}
|
||||
|
||||
public function testGetGuestNameThrows() {
|
||||
public function testGetGuestNameThrows(): void {
|
||||
$actorId = sha1('name');
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$this->participantService->method('getParticipantByActor')
|
||||
|
|
@ -1423,10 +1383,8 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataParseCall
|
||||
* @param array $parameters
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testParseCall(string $message, array $parameters, array $actor, array $expected) {
|
||||
public function testParseCall(string $message, array $parameters, array $actor, array $expected): void {
|
||||
$parser = $this->getParser(['getDuration', 'getUser']);
|
||||
$parser->expects($this->once())
|
||||
->method('getDuration')
|
||||
|
|
@ -1456,10 +1414,8 @@ class SystemMessageTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetDuration
|
||||
* @param int $seconds
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testGetDuration(int $seconds, string $expected) {
|
||||
public function testGetDuration(int $seconds, string $expected): void {
|
||||
$parser = $this->getParser();
|
||||
$this->assertSame($expected, self::invokePrivate($parser, 'getDuration', [$seconds]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,21 +44,14 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class UserMentionTest extends TestCase {
|
||||
/** @var ICommentsManager|MockObject */
|
||||
protected $commentsManager;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var IGroupManager */
|
||||
protected $groupManager;
|
||||
/** @var GuestManager|MockObject */
|
||||
protected $guestManager;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
protected ICloudIdManager|MockObject $cloudIdManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l;
|
||||
protected ICommentsManager&MockObject $commentsManager;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected GuestManager&MockObject $guestManager;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected ICloudIdManager&MockObject $cloudIdManager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected IL10N&MockObject $l;
|
||||
|
||||
protected ?UserMention $parser = null;
|
||||
|
||||
|
|
@ -98,14 +91,14 @@ class UserMentionTest extends TestCase {
|
|||
return $comment;
|
||||
}
|
||||
|
||||
public function testGetRichMessageWithoutEnrichableReferences() {
|
||||
public function testGetRichMessageWithoutEnrichableReferences(): void {
|
||||
$comment = $this->newComment([]);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Message without enrichable references', []);
|
||||
|
|
@ -132,11 +125,11 @@ class UserMentionTest extends TestCase {
|
|||
->with('testUser')
|
||||
->willReturn('testUser display name');
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @testUser', []);
|
||||
|
|
@ -155,7 +148,7 @@ class UserMentionTest extends TestCase {
|
|||
$this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters());
|
||||
}
|
||||
|
||||
public function testGetRichMessageWithDuplicatedMention() {
|
||||
public function testGetRichMessageWithDuplicatedMention(): void {
|
||||
$mentions = [
|
||||
['type' => 'user', 'id' => 'testUser'],
|
||||
];
|
||||
|
|
@ -171,11 +164,11 @@ class UserMentionTest extends TestCase {
|
|||
->with('testUser')
|
||||
->willReturn('testUser display name');
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @testUser and @testUser again', []);
|
||||
|
|
@ -194,7 +187,7 @@ class UserMentionTest extends TestCase {
|
|||
$this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters());
|
||||
}
|
||||
|
||||
public static function dataGetRichMessageWithMentionsFullyIncludedInOtherMentions() {
|
||||
public static function dataGetRichMessageWithMentionsFullyIncludedInOtherMentions(): array {
|
||||
// Based on valid characters from server/lib/private/User/Manager.php
|
||||
return [
|
||||
['testUser', 'testUser1', false],
|
||||
|
|
@ -215,7 +208,7 @@ class UserMentionTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider dataGetRichMessageWithMentionsFullyIncludedInOtherMentions
|
||||
*/
|
||||
public function testGetRichMessageWithMentionsFullyIncludedInOtherMentions(string $baseId, string $longerId, bool $quoted) {
|
||||
public function testGetRichMessageWithMentionsFullyIncludedInOtherMentions(string $baseId, string $longerId, bool $quoted): void {
|
||||
$mentions = [
|
||||
['type' => 'user', 'id' => $baseId],
|
||||
['type' => 'user', 'id' => $longerId],
|
||||
|
|
@ -235,11 +228,11 @@ class UserMentionTest extends TestCase {
|
|||
[$baseId, $baseId . ' display name']
|
||||
]);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
if ($quoted) {
|
||||
|
|
@ -267,7 +260,7 @@ class UserMentionTest extends TestCase {
|
|||
$this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters());
|
||||
}
|
||||
|
||||
public function testGetRichMessageWithSeveralMentions() {
|
||||
public function testGetRichMessageWithSeveralMentions(): void {
|
||||
$mentions = [
|
||||
['type' => 'user', 'id' => 'testUser1'],
|
||||
['type' => 'user', 'id' => 'testUser2'],
|
||||
|
|
@ -291,11 +284,11 @@ class UserMentionTest extends TestCase {
|
|||
['testUser3', 'testUser3 display name'],
|
||||
]);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @testUser1, @testUser2, @testUser1 again and @testUser3', []);
|
||||
|
|
@ -324,7 +317,7 @@ class UserMentionTest extends TestCase {
|
|||
$this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters());
|
||||
}
|
||||
|
||||
public function testGetRichMessageWithNonExistingUserMention() {
|
||||
public function testGetRichMessageWithNonExistingUserMention(): void {
|
||||
$mentions = [
|
||||
['type' => 'user', 'id' => 'me'],
|
||||
['type' => 'user', 'id' => 'testUser'],
|
||||
|
|
@ -343,11 +336,11 @@ class UserMentionTest extends TestCase {
|
|||
['testUser', 'testUser display name'],
|
||||
]);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention @me to @testUser', []);
|
||||
|
|
@ -366,7 +359,7 @@ class UserMentionTest extends TestCase {
|
|||
$this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters());
|
||||
}
|
||||
|
||||
public function testGetRichMessageWhenDisplayNameCanNotBeResolved() {
|
||||
public function testGetRichMessageWhenDisplayNameCanNotBeResolved(): void {
|
||||
$mentions = [
|
||||
['type' => 'user', 'id' => 'testUser'],
|
||||
];
|
||||
|
|
@ -381,11 +374,11 @@ class UserMentionTest extends TestCase {
|
|||
->with('testUser')
|
||||
->willReturn('existing user but does not resolve later');
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @testUser', []);
|
||||
|
|
@ -410,7 +403,7 @@ class UserMentionTest extends TestCase {
|
|||
];
|
||||
$comment = $this->newComment($mentions);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->expects($this->once())
|
||||
->method('getType')
|
||||
|
|
@ -421,9 +414,9 @@ class UserMentionTest extends TestCase {
|
|||
$room->expects($this->once())
|
||||
->method('getDisplayName')
|
||||
->willReturn('name');
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @all', []);
|
||||
|
|
@ -454,11 +447,11 @@ class UserMentionTest extends TestCase {
|
|||
];
|
||||
$comment = $this->newComment($mentions);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$chatMessage = new Message($room, $participant, $comment, $l);
|
||||
$chatMessage->setMessage('Mention to @"federated_user/testUser@example.tld"', []);
|
||||
|
|
@ -495,11 +488,11 @@ class UserMentionTest extends TestCase {
|
|||
];
|
||||
$comment = $this->newComment($mentions);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
|
||||
$this->participantService->method('getParticipantByActor')
|
||||
|
|
@ -534,11 +527,11 @@ class UserMentionTest extends TestCase {
|
|||
];
|
||||
$comment = $this->newComment($mentions);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
|
||||
$this->participantService->method('getParticipantByActor')
|
||||
|
|
@ -573,11 +566,11 @@ class UserMentionTest extends TestCase {
|
|||
];
|
||||
$comment = $this->newComment($mentions);
|
||||
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
/** @var Participant|MockObject $participant */
|
||||
/** @var Participant&MockObject $participant */
|
||||
$participant = $this->createMock(Participant::class);
|
||||
/** @var IL10N|MockObject $l */
|
||||
/** @var IL10N&MockObject $l */
|
||||
$l = $this->createMock(IL10N::class);
|
||||
|
||||
$attendee = Attendee::fromRow([
|
||||
|
|
|
|||
|
|
@ -54,31 +54,20 @@ use Test\TestCase;
|
|||
class ListenerTest extends TestCase {
|
||||
public const DUMMY_REFERENCE_ID = 'DUMMY_REFERENCE_ID';
|
||||
|
||||
protected ?Listener $listener = null;
|
||||
|
||||
/** @var IRequest|MockObject */
|
||||
protected $request;
|
||||
/** @var ChatManager|MockObject */
|
||||
protected $chatManager;
|
||||
/** @var IUserSession|MockObject */
|
||||
protected $userSession;
|
||||
/** @var ISession|MockObject */
|
||||
protected $session;
|
||||
/** @var TalkSession|MockObject */
|
||||
protected $talkSession;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $eventDispatcher;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var MessageParser|MockObject */
|
||||
protected $messageParser;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
protected IRequest&MockObject $request;
|
||||
protected ChatManager&MockObject $chatManager;
|
||||
protected IUserSession&MockObject $userSession;
|
||||
protected ISession&MockObject $session;
|
||||
protected TalkSession&MockObject $talkSession;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IEventDispatcher&MockObject $eventDispatcher;
|
||||
protected Manager&MockObject $manager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected MessageParser&MockObject $messageParser;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected ?array $handlers = null;
|
||||
protected ?\DateTime $dummyTime = null;
|
||||
protected ?Listener $listener = null;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -36,19 +36,15 @@ use OCP\Collaboration\Collaborators\SearchResultType;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Share\IShare;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class RoomPluginTest extends TestCase {
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected ?Manager $manager = null;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
|
||||
protected ?IUserSession $userSession = null;
|
||||
|
||||
protected ?IUser $user = null;
|
||||
|
||||
protected ?ISearchResult $searchResult = null;
|
||||
|
||||
protected ?RoomPlugin $plugin = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -234,14 +230,6 @@ class RoomPluginTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSearch
|
||||
*
|
||||
* @param string $searchTerm
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @param array $roomsForParticipant
|
||||
* @param array $expectedMatchesExact
|
||||
* @param array $expectedMatches
|
||||
* @param bool $expectedHasMoreResults
|
||||
*/
|
||||
public function testSearch(
|
||||
string $searchTerm,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
|
||||
|
|
@ -36,20 +35,13 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class TalkReferenceProviderTest extends TestCase {
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $urlGenerator;
|
||||
/** @var Manager|MockObject */
|
||||
protected $roomManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var ChatManager|MockObject */
|
||||
protected $chatManager;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var MessageParser|MockObject */
|
||||
protected $messageParser;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l;
|
||||
protected IURLGenerator&MockObject $urlGenerator;
|
||||
protected Manager&MockObject $roomManager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected ChatManager&MockObject $chatManager;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected MessageParser&MockObject $messageParser;
|
||||
protected IL10N&MockObject $l;
|
||||
protected ?TalkReferenceProvider $provider = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -90,9 +82,6 @@ class TalkReferenceProviderTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGetTalkAppLinkToken
|
||||
* @param string $reference
|
||||
* @param array|null $expected
|
||||
* @return void
|
||||
*/
|
||||
public function testGetTalkAppLinkToken(string $reference, ?array $expected): void {
|
||||
$this->urlGenerator->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -41,16 +41,11 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class ConversationProviderTest extends TestCase {
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var IUserSession|MockObject */
|
||||
protected $userSession;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $urlGenerator;
|
||||
protected Manager&MockObject $manager;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected IUserSession&MockObject $userSession;
|
||||
protected IURLGenerator&MockObject $urlGenerator;
|
||||
protected ?ConversationProvider $provider = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -165,7 +160,6 @@ class ConversationProviderTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCanAccessResourceYes
|
||||
* @param int $participantType
|
||||
*/
|
||||
public function testCanAccessResourceYes(int $participantType): void {
|
||||
$user = $this->createMock(IUser::class);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Signaling;
|
|||
|
||||
use OCA\Talk\Command\Signaling\Add;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class AddTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Add|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Add $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class AddTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testServerEmptyString() {
|
||||
public function testServerEmptyString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
|
|
@ -71,10 +67,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testSecretEmptyString() {
|
||||
public function testSecretEmptyString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
|
|
@ -93,10 +89,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToEmptyList() {
|
||||
public function testAddServerToEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
|
|
@ -132,10 +128,10 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added signaling server wss://signaling.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToNonEmptyList() {
|
||||
public function testAddServerToNonEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
|
|
@ -183,6 +179,6 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added signaling server wss://signaling2.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Signaling;
|
|||
|
||||
use OCA\Talk\Command\Signaling\Delete;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Delete|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Delete $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class DeleteTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testDeleteIfEmpty() {
|
||||
public function testDeleteIfEmpty(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling.example.com');
|
||||
|
|
@ -74,10 +70,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
public function testDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling2.test.com');
|
||||
|
|
@ -124,10 +120,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Deleted wss://signaling2.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testNothingToDelete() {
|
||||
public function testNothingToDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling4.test.com');
|
||||
|
|
@ -162,6 +158,6 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Signaling;
|
|||
|
||||
use OCA\Talk\Command\Signaling\ListCommand;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class ListCommandTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var ListCommand|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected ListCommand&MockObject $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -55,7 +51,7 @@ class ListCommandTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testEmptyAppConfig() {
|
||||
public function testEmptyAppConfig(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
|
|
@ -69,10 +65,10 @@ class ListCommandTest extends TestCase {
|
|||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAppConfigDataChanges() {
|
||||
public function testAppConfigDataChanges(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
|
|
@ -102,6 +98,6 @@ class ListCommandTest extends TestCase {
|
|||
])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Stun;
|
|||
|
||||
use OCA\Talk\Command\Stun\Add;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class AddTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Add|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Add $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class AddTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testMalformedServerString() {
|
||||
public function testMalformedServerString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun.test.com');
|
||||
|
|
@ -62,10 +58,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToEmptyList() {
|
||||
public function testAddServerToEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun.test.com:443');
|
||||
|
|
@ -83,10 +79,10 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added stun.test.com:443.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToNonEmptyList() {
|
||||
public function testAddServerToNonEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun2.test.com:443');
|
||||
|
|
@ -104,6 +100,6 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added stun2.test.com:443.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Stun;
|
|||
|
||||
use OCA\Talk\Command\Stun\Delete;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Delete|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Delete $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class DeleteTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testAddDefaultServerIfEmpty() {
|
||||
public function testAddDefaultServerIfEmpty(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun1.test.com:443');
|
||||
|
|
@ -71,10 +67,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>You deleted all STUN servers. A default STUN server was added.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
public function testDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun1.test.com:443');
|
||||
|
|
@ -93,10 +89,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Deleted stun1.test.com:443.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testNothingToDelete() {
|
||||
public function testNothingToDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('stun3.test.com:443');
|
||||
|
|
@ -115,6 +111,6 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Stun;
|
|||
|
||||
use OCA\Talk\Command\Stun\ListCommand;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class ListCommandTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var ListCommand|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected ListCommand&MockObject $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -55,7 +51,7 @@ class ListCommandTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testEmptyAppConfig() {
|
||||
public function testEmptyAppConfig(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'stun_servers')
|
||||
|
|
@ -69,10 +65,10 @@ class ListCommandTest extends TestCase {
|
|||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAppConfigDataChanges() {
|
||||
public function testAppConfigDataChanges(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'stun_servers')
|
||||
|
|
@ -92,6 +88,6 @@ class ListCommandTest extends TestCase {
|
|||
])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Turn;
|
|||
|
||||
use OCA\Talk\Command\Turn\Add;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class AddTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Add|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Add $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class AddTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testServerEmptyString() {
|
||||
public function testServerEmptyString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -79,10 +75,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testSecretEmpty() {
|
||||
public function testSecretEmpty(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -109,10 +105,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testGenerateSecret() {
|
||||
public function testGenerateSecret(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -162,10 +158,10 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added turn.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testSecretAndGenerateSecretOptions() {
|
||||
public function testSecretAndGenerateSecretOptions(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -192,10 +188,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testInvalidSchemesString() {
|
||||
public function testInvalidSchemesString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -222,10 +218,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testInvalidProtocolsString() {
|
||||
public function testInvalidProtocolsString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -252,10 +248,10 @@ class AddTest extends TestCase {
|
|||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToEmptyList() {
|
||||
public function testAddServerToEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -297,10 +293,10 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added turn.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToNonEmptyList() {
|
||||
public function testAddServerToNonEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -353,10 +349,10 @@ class AddTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added turn2.test.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testServerSanitization() {
|
||||
public function testServerSanitization(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -395,6 +391,6 @@ class AddTest extends TestCase {
|
|||
]))
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Turn;
|
|||
|
||||
use OCA\Talk\Command\Turn\Delete;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var Delete|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Delete $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -52,7 +48,7 @@ class DeleteTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testDeleteIfEmpty() {
|
||||
public function testDeleteIfEmpty(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -79,10 +75,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
public function testDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -123,10 +119,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testNothingToDelete() {
|
||||
public function testNothingToDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -191,10 +187,10 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testDeleteMatchingSchemes() {
|
||||
public function testDeleteMatchingSchemes(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'schemes') {
|
||||
|
|
@ -241,6 +237,6 @@ class DeleteTest extends TestCase {
|
|||
->method('writeln')
|
||||
->with($this->equalTo('<info>Deleted turn.example.com.</info>'));
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
|
||||
*
|
||||
|
|
@ -24,22 +26,16 @@ namespace OCA\Talk\Tests\php\Command\Turn;
|
|||
|
||||
use OCA\Talk\Command\Turn\ListCommand;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class ListCommandTest extends TestCase {
|
||||
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
/** @var ListCommand|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $command;
|
||||
|
||||
/** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $input;
|
||||
|
||||
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $output;
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected ListCommand&MockObject $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -55,7 +51,7 @@ class ListCommandTest extends TestCase {
|
|||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testEmptyAppConfig() {
|
||||
public function testEmptyAppConfig(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'turn_servers')
|
||||
|
|
@ -69,10 +65,10 @@ class ListCommandTest extends TestCase {
|
|||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAppConfigDataChanges() {
|
||||
public function testAppConfigDataChanges(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'turn_servers')
|
||||
|
|
@ -108,6 +104,6 @@ class ListCommandTest extends TestCase {
|
|||
])
|
||||
);
|
||||
|
||||
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
|
|
@ -58,7 +60,7 @@ class ConfigTest extends TestCase {
|
|||
return $helper;
|
||||
}
|
||||
|
||||
public function testGetStunServers() {
|
||||
public function testGetStunServers(): void {
|
||||
$servers = [
|
||||
'stun1.example.com:443',
|
||||
'stun2.example.com:129',
|
||||
|
|
@ -81,7 +83,7 @@ class ConfigTest extends TestCase {
|
|||
$this->assertSame($helper->getStunServers(), $servers);
|
||||
}
|
||||
|
||||
public function testGetDefaultStunServer() {
|
||||
public function testGetDefaultStunServer(): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
|
|
@ -99,7 +101,7 @@ class ConfigTest extends TestCase {
|
|||
$this->assertSame(['stun.nextcloud.com:443'], $helper->getStunServers());
|
||||
}
|
||||
|
||||
public function testGetDefaultStunServerNoInternet() {
|
||||
public function testGetDefaultStunServerNoInternet(): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
|
|
@ -117,7 +119,7 @@ class ConfigTest extends TestCase {
|
|||
$this->assertSame([], $helper->getStunServers());
|
||||
}
|
||||
|
||||
public function testGenerateTurnSettings() {
|
||||
public function testGenerateTurnSettings(): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
|
|
@ -198,7 +200,7 @@ class ConfigTest extends TestCase {
|
|||
], $settings[2]);
|
||||
}
|
||||
|
||||
public function testGenerateTurnSettingsEmpty() {
|
||||
public function testGenerateTurnSettingsEmpty(): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
|
|
@ -213,7 +215,7 @@ class ConfigTest extends TestCase {
|
|||
$this->assertEquals(0, count($settings));
|
||||
}
|
||||
|
||||
public function testGenerateTurnSettingsEvent() {
|
||||
public function testGenerateTurnSettingsEvent(): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
|
|
@ -241,7 +243,7 @@ class ConfigTest extends TestCase {
|
|||
$secureRandom = $this->createMock(ISecureRandom::class);
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = \OC::$server->get(IEventDispatcher::class);
|
||||
$dispatcher = \OCP\Server::get(IEventDispatcher::class);
|
||||
|
||||
$servers = [
|
||||
[
|
||||
|
|
@ -268,7 +270,7 @@ class ConfigTest extends TestCase {
|
|||
$this->assertSame($servers, $settings);
|
||||
}
|
||||
|
||||
public static function dataGetWebSocketDomainForSignalingServer() {
|
||||
public static function dataGetWebSocketDomainForSignalingServer(): array {
|
||||
return [
|
||||
['http://blabla.nextcloud.com', 'ws://blabla.nextcloud.com'],
|
||||
['http://blabla.nextcloud.com/', 'ws://blabla.nextcloud.com'],
|
||||
|
|
@ -329,7 +331,7 @@ class ConfigTest extends TestCase {
|
|||
* @param string $url
|
||||
* @param string $expectedWebSocketDomain
|
||||
*/
|
||||
public function testGetWebSocketDomainForSignalingServer($url, $expectedWebSocketDomain) {
|
||||
public function testGetWebSocketDomainForSignalingServer($url, $expectedWebSocketDomain): void {
|
||||
/** @var MockObject|IConfig $config */
|
||||
$config = $this->createMock(IConfig::class);
|
||||
|
||||
|
|
@ -341,7 +343,7 @@ class ConfigTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public static function dataTicketV2Algorithm() {
|
||||
public static function dataTicketV2Algorithm(): array {
|
||||
return [
|
||||
['ES384'],
|
||||
['ES256'],
|
||||
|
|
@ -354,11 +356,9 @@ class ConfigTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataTicketV2Algorithm
|
||||
* @param string $algo
|
||||
*/
|
||||
public function testSignalingTicketV2User(string $algo): void {
|
||||
/** @var IConfig $config */
|
||||
$config = \OC::$server->getConfig();
|
||||
$config = \OCP\Server::get(IConfig::class);
|
||||
/** @var MockObject|IAppConfig $appConfig */
|
||||
$appConfig = $this->createMock(IAppConfig::class);
|
||||
/** @var MockObject|ITimeFactory $timeFactory */
|
||||
|
|
@ -420,11 +420,10 @@ class ConfigTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataTicketV2Algorithm
|
||||
* @param string $algo
|
||||
*/
|
||||
public function testSignalingTicketV2Anonymous(string $algo): void {
|
||||
/** @var IConfig $config */
|
||||
$config = \OC::$server->getConfig();
|
||||
$config = \OCP\Server::get(IConfig::class);
|
||||
/** @var MockObject|IAppConfig $appConfig */
|
||||
$appConfig = $this->createMock(IAppConfig::class);
|
||||
/** @var MockObject|ITimeFactory $timeFactory */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -68,60 +69,36 @@ use Test\TestCase;
|
|||
|
||||
class ChatControllerTest extends TestCase {
|
||||
private ?string $userId = null;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var IAppManager|MockObject */
|
||||
private $appManager;
|
||||
/** @var ChatManager|MockObject */
|
||||
protected $chatManager;
|
||||
private RoomFormatter|MockObject $roomFormatter;
|
||||
/** @var ReactionManager|MockObject */
|
||||
protected $reactionManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var SessionService|MockObject */
|
||||
protected $sessionService;
|
||||
/** @var AttachmentService|MockObject */
|
||||
protected $attachmentService;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var ReminderService|MockObject */
|
||||
protected $reminderService;
|
||||
/** @var GuestManager|MockObject */
|
||||
protected $guestManager;
|
||||
/** @var MessageParser|MockObject */
|
||||
protected $messageParser;
|
||||
/** @var RoomShareProvider|MockObject */
|
||||
protected $roomShareProvider;
|
||||
/** @var FilesMetadataCache|MockObject */
|
||||
protected $filesMetadataCache;
|
||||
/** @var IManager|MockObject */
|
||||
protected $autoCompleteManager;
|
||||
/** @var IUserStatusManager|MockObject */
|
||||
protected $statusManager;
|
||||
/** @var MatterbridgeManager|MockObject */
|
||||
protected $matterbridgeManager;
|
||||
protected BotService|MockObject $botService;
|
||||
/** @var SearchPlugin|MockObject */
|
||||
protected $searchPlugin;
|
||||
/** @var ISearchResult|MockObject */
|
||||
protected $searchResult;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $eventDispatcher;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IValidator|MockObject */
|
||||
protected $richObjectValidator;
|
||||
/** @var ITrustedDomainHelper|MockObject */
|
||||
protected $trustedDomainHelper;
|
||||
/** @var IL10N|MockObject */
|
||||
private $l;
|
||||
private Authenticator|MockObject $federationAuthenticator;
|
||||
private ProxyCacheMessageService|MockObject $pcmService;
|
||||
private Notifier|MockObject $notifier;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IAppManager&MockObject $appManager;
|
||||
protected ChatManager&MockObject $chatManager;
|
||||
private RoomFormatter&MockObject $roomFormatter;
|
||||
protected ReactionManager&MockObject $reactionManager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected SessionService&MockObject $sessionService;
|
||||
protected AttachmentService&MockObject $attachmentService;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected ReminderService&MockObject $reminderService;
|
||||
protected GuestManager&MockObject $guestManager;
|
||||
protected MessageParser&MockObject $messageParser;
|
||||
protected RoomShareProvider&MockObject $roomShareProvider;
|
||||
protected FilesMetadataCache&MockObject $filesMetadataCache;
|
||||
protected IManager&MockObject $autoCompleteManager;
|
||||
protected IUserStatusManager&MockObject $statusManager;
|
||||
protected MatterbridgeManager&MockObject $matterbridgeManager;
|
||||
protected BotService&MockObject $botService;
|
||||
protected SearchPlugin&MockObject $searchPlugin;
|
||||
protected ISearchResult&MockObject $searchResult;
|
||||
protected IEventDispatcher&MockObject $eventDispatcher;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IValidator&MockObject $richObjectValidator;
|
||||
protected ITrustedDomainHelper&MockObject $trustedDomainHelper;
|
||||
protected IL10N&MockObject $l;
|
||||
private Authenticator&MockObject $federationAuthenticator;
|
||||
private ProxyCacheMessageService&MockObject $pcmService;
|
||||
private Notifier&MockObject $notifier;
|
||||
|
||||
/** @var Room|MockObject */
|
||||
protected $room;
|
||||
protected Room&MockObject $room;
|
||||
|
||||
private ?ChatController $controller = null;
|
||||
|
||||
|
|
@ -222,14 +199,14 @@ class ChatControllerTest extends TestCase {
|
|||
return $comment;
|
||||
}
|
||||
|
||||
public function testSendMessageByUser() {
|
||||
public function testSendMessageByUser(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$date = new \DateTime();
|
||||
$this->timeFactory->expects($this->once())
|
||||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(42, 'user', $this->userId, $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('sendMessage')
|
||||
|
|
@ -293,14 +270,14 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testSendMessageByUserWithReferenceId() {
|
||||
public function testSendMessageByUserWithReferenceId(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$date = new \DateTime();
|
||||
$this->timeFactory->expects($this->once())
|
||||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(42, 'user', $this->userId, $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('sendMessage')
|
||||
|
|
@ -364,7 +341,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testSendReplyByUser() {
|
||||
public function testSendReplyByUser(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$date = new \DateTime();
|
||||
|
|
@ -372,10 +349,10 @@ class ChatControllerTest extends TestCase {
|
|||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$parent = $this->newComment(23, 'users', $this->userId . '2', $date, 'testMessage original');
|
||||
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(42, 'users', $this->userId, $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('sendMessage')
|
||||
|
|
@ -490,11 +467,11 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testSendReplyByUserToNotReplyable() {
|
||||
public function testSendReplyByUserToNotReplyable(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$date = new \DateTime();
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$parent = $this->newComment(23, 'user', $this->userId . '2', $date, 'testMessage original');
|
||||
|
||||
$this->chatManager->expects($this->never())
|
||||
|
|
@ -526,14 +503,14 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testSendMessageByUserNotJoinedButInRoom() {
|
||||
public function testSendMessageByUserNotJoinedButInRoom(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$date = new \DateTime();
|
||||
$this->timeFactory->expects($this->once())
|
||||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(23, 'user', $this->userId, $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('sendMessage')
|
||||
|
|
@ -595,7 +572,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testSendMessageByGuest() {
|
||||
public function testSendMessageByGuest(): void {
|
||||
$this->userId = null;
|
||||
$this->recreateChatController();
|
||||
|
||||
|
|
@ -612,7 +589,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->timeFactory->expects($this->once())
|
||||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(64, 'guest', sha1('testSpreedSession'), $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('sendMessage')
|
||||
|
|
@ -674,7 +651,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testShareObjectToChatByUser() {
|
||||
public function testShareObjectToChatByUser(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$this->avatarService->method('getAvatarUrl')
|
||||
|
|
@ -692,7 +669,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->timeFactory->expects($this->once())
|
||||
->method('getDateTime')
|
||||
->willReturn($date);
|
||||
/** @var IComment|MockObject $comment */
|
||||
/** @var IComment&MockObject $comment */
|
||||
$comment = $this->newComment(42, 'user', $this->userId, $date, 'testMessage');
|
||||
$this->chatManager->expects($this->once())
|
||||
->method('addSystemMessage')
|
||||
|
|
@ -768,7 +745,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected->getData(), $response->getData());
|
||||
}
|
||||
|
||||
public function testReceiveHistoryByUser() {
|
||||
public function testReceiveHistoryByUser(): void {
|
||||
$offset = 23;
|
||||
$limit = 4;
|
||||
$this->chatManager->expects($this->once())
|
||||
|
|
@ -837,7 +814,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testReceiveMessagesByUserNotJoinedButInRoom() {
|
||||
public function testReceiveMessagesByUserNotJoinedButInRoom(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
|
||||
$offset = 23;
|
||||
|
|
@ -906,7 +883,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testReceiveMessagesByGuest() {
|
||||
public function testReceiveMessagesByGuest(): void {
|
||||
$this->userId = null;
|
||||
$this->recreateChatController();
|
||||
|
||||
|
|
@ -978,7 +955,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testWaitForNewMessagesByUser() {
|
||||
public function testWaitForNewMessagesByUser(): void {
|
||||
$testUser = $this->createMock(IUser::class);
|
||||
$testUser->expects($this->any())
|
||||
->method('getUID')
|
||||
|
|
@ -1058,7 +1035,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testWaitForNewMessagesTimeoutExpired() {
|
||||
public function testWaitForNewMessagesTimeoutExpired(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$testUser = $this->createMock(IUser::class);
|
||||
$testUser->expects($this->any())
|
||||
|
|
@ -1086,7 +1063,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public function testWaitForNewMessagesTimeoutTooLarge() {
|
||||
public function testWaitForNewMessagesTimeoutTooLarge(): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$testUser = $this->createMock(IUser::class);
|
||||
$testUser->expects($this->any())
|
||||
|
|
@ -1115,7 +1092,7 @@ class ChatControllerTest extends TestCase {
|
|||
$this->assertEquals($expected, $response);
|
||||
}
|
||||
|
||||
public static function dataMentions() {
|
||||
public static function dataMentions(): array {
|
||||
return [
|
||||
['tes', 10, ['exact' => []], []],
|
||||
[
|
||||
|
|
@ -1146,7 +1123,7 @@ class ChatControllerTest extends TestCase {
|
|||
/**
|
||||
* @dataProvider dataMentions
|
||||
*/
|
||||
public function testMentions($search, $limit, $result, $expected) {
|
||||
public function testMentions(string $search, int $limit, array $result, array $expected): void {
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$this->room->expects($this->any())
|
||||
->method('getId')
|
||||
|
|
|
|||
|
|
@ -77,37 +77,24 @@ class CustomInputSignalingController extends SignalingController {
|
|||
* @group DB
|
||||
*/
|
||||
class SignalingControllerTest extends TestCase {
|
||||
private IConfig $serverConfig;
|
||||
private ?Config $config = null;
|
||||
/** @var TalkSession|MockObject */
|
||||
private $session;
|
||||
/** @var \OCA\Talk\Signaling\Manager|MockObject */
|
||||
private $signalingManager;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var CertificateService|MockObject */
|
||||
protected $certificateService;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var SessionService|MockObject */
|
||||
protected $sessionService;
|
||||
/** @var IDBConnection|MockObject */
|
||||
protected $dbConnection;
|
||||
/** @var Messages|MockObject */
|
||||
protected $messages;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IClientService|MockObject */
|
||||
protected $clientService;
|
||||
private ?string $userId = null;
|
||||
private ?ISecureRandom $secureRandom = null;
|
||||
private ?IEventDispatcher $dispatcher = null;
|
||||
/** @var IThrottler|MockObject */
|
||||
private $throttler;
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
protected TalkSession&MockObject $session;
|
||||
protected \OCA\Talk\Signaling\Manager&MockObject $signalingManager;
|
||||
protected Manager|MockObject $manager;
|
||||
protected CertificateService&MockObject $certificateService;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected SessionService&MockObject $sessionService;
|
||||
protected Messages&MockObject $messages;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IClientService&MockObject $clientService;
|
||||
protected IThrottler&MockObject $throttler;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected IDBConnection $dbConnection;
|
||||
protected IConfig $serverConfig;
|
||||
protected ?Config $config = null;
|
||||
protected ?string $userId = null;
|
||||
protected ?ISecureRandom $secureRandom = null;
|
||||
protected ?IEventDispatcher $dispatcher = null;
|
||||
|
||||
private ?CustomInputSignalingController $controller = null;
|
||||
|
||||
|
|
@ -115,23 +102,23 @@ class SignalingControllerTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->userId = 'testUser';
|
||||
$this->secureRandom = \OC::$server->getSecureRandom();
|
||||
$this->secureRandom = \OCP\Server::get(ISecureRandom::class);
|
||||
/** @var MockObject|IAppConfig $appConfig */
|
||||
$appConfig = $this->createMock(IAppConfig::class);
|
||||
$timeFactory = $this->createMock(ITimeFactory::class);
|
||||
$groupManager = $this->createMock(IGroupManager::class);
|
||||
$this->serverConfig = \OC::$server->getConfig();
|
||||
$this->serverConfig = \OCP\Server::get(IConfig::class);
|
||||
$this->serverConfig->setAppValue('spreed', 'signaling_servers', json_encode([
|
||||
'secret' => 'MySecretValue',
|
||||
]));
|
||||
$this->serverConfig->setAppValue('spreed', 'signaling_ticket_secret', 'the-app-ticket-secret');
|
||||
$this->serverConfig->setUserValue($this->userId, 'spreed', 'signaling_ticket_secret', 'the-user-ticket-secret');
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->dispatcher = \OC::$server->get(IEventDispatcher::class);
|
||||
$this->dispatcher = \OCP\Server::get(IEventDispatcher::class);
|
||||
$urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->config = new Config($this->serverConfig, $appConfig, $this->secureRandom, $groupManager, $this->userManager, $urlGenerator, $timeFactory, $this->dispatcher);
|
||||
$this->session = $this->createMock(TalkSession::class);
|
||||
$this->dbConnection = \OC::$server->getDatabaseConnection();
|
||||
$this->dbConnection = \OCP\Server::get(IDBConnection::class);
|
||||
$this->signalingManager = $this->createMock(\OCA\Talk\Signaling\Manager::class);
|
||||
$this->manager = $this->createMock(Manager::class);
|
||||
$this->certificateService = $this->createMock(CertificateService::class);
|
||||
|
|
@ -185,7 +172,7 @@ class SignalingControllerTest extends TestCase {
|
|||
return $hash;
|
||||
}
|
||||
|
||||
public function testBackendChecksums() {
|
||||
public function testBackendChecksums(): void {
|
||||
// Test checksum generation / validation with the example from the API documentation.
|
||||
$data = '{"type":"auth","auth":{"version":"1.0","params":{"hello":"world"}}}';
|
||||
$random = 'afb6b872ab03e3376b31bf0af601067222ff7990335ca02d327071b73c0119c6';
|
||||
|
|
@ -206,7 +193,7 @@ class SignalingControllerTest extends TestCase {
|
|||
return $this->controller->backend();
|
||||
}
|
||||
|
||||
public function testBackendChecksumValidation() {
|
||||
public function testBackendChecksumValidation(): void {
|
||||
$data = '{}';
|
||||
|
||||
// Random and checksum missing.
|
||||
|
|
@ -251,7 +238,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendUnsupportedType() {
|
||||
public function testBackendUnsupportedType(): void {
|
||||
$result = $this->performBackendRequest([
|
||||
'type' => 'unsupported-type',
|
||||
]);
|
||||
|
|
@ -264,7 +251,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendAuth() {
|
||||
public function testBackendAuth(): void {
|
||||
// Check validating of tickets.
|
||||
$result = $this->performBackendRequest([
|
||||
'type' => 'auth',
|
||||
|
|
@ -369,7 +356,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomUnknown() {
|
||||
public function testBackendRoomUnknown(): void {
|
||||
$roomToken = 'the-room';
|
||||
$room = $this->createMock(Room::class);
|
||||
$this->manager->expects($this->once())
|
||||
|
|
@ -394,7 +381,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomInvited() {
|
||||
public function testBackendRoomInvited(): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -455,7 +442,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomUserPublic() {
|
||||
public function testBackendRoomUserPublic(): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -516,7 +503,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomModeratorPublic() {
|
||||
public function testBackendRoomModeratorPublic(): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -582,7 +569,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomAnonymousPublic() {
|
||||
public function testBackendRoomAnonymousPublic(): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$sessionId = 'the-session';
|
||||
|
|
@ -644,7 +631,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomInvitedPublic() {
|
||||
public function testBackendRoomInvitedPublic(): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$sessionId = 'the-session';
|
||||
|
|
@ -721,11 +708,8 @@ class SignalingControllerTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataBackendRoomUserPublicPermissions
|
||||
*
|
||||
* @param int $permissions
|
||||
* @param array $expectedBackendPermissions
|
||||
*/
|
||||
public function testBackendRoomUserPublicPermissions(int $permissions, array $expectedBackendPermissions) {
|
||||
public function testBackendRoomUserPublicPermissions(int $permissions, array $expectedBackendPermissions): void {
|
||||
$roomToken = 'the-room';
|
||||
$roomName = 'the-room-name';
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -782,7 +766,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomAnonymousOneToOne() {
|
||||
public function testBackendRoomAnonymousOneToOne(): void {
|
||||
$roomToken = 'the-room';
|
||||
$sessionId = 'the-session';
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -812,7 +796,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendRoomSessionFromEvent() {
|
||||
public function testBackendRoomSessionFromEvent(): void {
|
||||
$this->dispatcher->addListener(BeforeSignalingResponseSentEvent::class, static function (BeforeSignalingResponseSentEvent $event) {
|
||||
$room = $event->getRoom();
|
||||
$event->setSession([
|
||||
|
|
@ -885,7 +869,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendPingUser() {
|
||||
public function testBackendPingUser(): void {
|
||||
$sessionId = 'the-session';
|
||||
|
||||
$this->timeFactory->method('getTime')
|
||||
|
|
@ -913,7 +897,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendPingAnonymous() {
|
||||
public function testBackendPingAnonymous(): void {
|
||||
$sessionId = 'the-session';
|
||||
|
||||
$this->timeFactory->method('getTime')
|
||||
|
|
@ -941,7 +925,7 @@ class SignalingControllerTest extends TestCase {
|
|||
], $result->getData());
|
||||
}
|
||||
|
||||
public function testBackendPingMixedAndInactive() {
|
||||
public function testBackendPingMixedAndInactive(): void {
|
||||
$sessionId = 'the-session';
|
||||
|
||||
$this->timeFactory->method('getTime')
|
||||
|
|
@ -978,21 +962,21 @@ class SignalingControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testLeaveRoomWithOldSession() {
|
||||
public function testLeaveRoomWithOldSession(): void {
|
||||
// Make sure that leaving a user with an old session id doesn't remove
|
||||
// the current user from the room if he re-joined in the meantime.
|
||||
$dbConnection = \OC::$server->getDatabaseConnection();
|
||||
$dispatcher = \OC::$server->get(IEventDispatcher::class);
|
||||
$dbConnection = \OCP\Server::get(IDBConnection::class);
|
||||
$dispatcher = \OCP\Server::get(IEventDispatcher::class);
|
||||
/** @var ParticipantService $participantService */
|
||||
$participantService = \OC::$server->get(ParticipantService::class);
|
||||
$participantService = \OCP\Server::get(ParticipantService::class);
|
||||
|
||||
$this->manager = new Manager(
|
||||
$dbConnection,
|
||||
\OC::$server->getConfig(),
|
||||
\OCP\Server::get(IConfig::class),
|
||||
$this->createMock(Config::class),
|
||||
\OC::$server->get(IAppManager::class),
|
||||
\OC::$server->get(AttendeeMapper::class),
|
||||
\OC::$server->get(SessionMapper::class),
|
||||
\OCP\Server::get(IAppManager::class),
|
||||
\OCP\Server::get(AttendeeMapper::class),
|
||||
\OCP\Server::get(SessionMapper::class),
|
||||
$participantService,
|
||||
$this->secureRandom,
|
||||
$this->createMock(IUserManager::class),
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class EventDocumentationTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataEventDocumentation
|
||||
* @param string $eventClass
|
||||
*/
|
||||
public function testEventDocumentation(string $eventClass): void {
|
||||
$reflectionClass = new \ReflectionClass($eventClass);
|
||||
|
|
|
|||
|
|
@ -66,49 +66,29 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class FederationTest extends TestCase {
|
||||
protected ?FederationManager $federationManager = null;
|
||||
|
||||
protected ?BackendNotifier $backendNotifier = null;
|
||||
|
||||
protected ICloudIdManager|MockObject $cloudIdManager;
|
||||
/** @var ICloudFederationProviderManager|MockObject */
|
||||
protected $cloudFederationProviderManager;
|
||||
|
||||
/** @var ICloudFederationFactory|MockObject */
|
||||
protected $cloudFederationFactory;
|
||||
|
||||
/** @var Config|MockObject */
|
||||
protected $config;
|
||||
protected IAppConfig|MockObject $appConfig;
|
||||
/** @var LoggerInterface|MockObject */
|
||||
protected $logger;
|
||||
|
||||
/** @var AddressHandler|MockObject */
|
||||
protected $addressHandler;
|
||||
|
||||
protected FederationManager&MockObject $federationManager;
|
||||
protected ICloudIdManager&MockObject $cloudIdManager;
|
||||
protected ICloudFederationProviderManager&MockObject $cloudFederationProviderManager;
|
||||
protected ICloudFederationFactory&MockObject $cloudFederationFactory;
|
||||
protected Config&MockObject $config;
|
||||
protected IAppConfig&MockObject $appConfig;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected AddressHandler&MockObject $addressHandler;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IAppManager&MockObject $appManager;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected INotificationManager&MockObject $notificationManager;
|
||||
protected AttendeeMapper&MockObject $attendeeMapper;
|
||||
protected ProxyCacheMessageMapper&MockObject $proxyCacheMessageMapper;
|
||||
protected ProxyCacheMessageService&MockObject $proxyCacheMessageService;
|
||||
protected FederationChatNotifier&MockObject $federationChatNotifier;
|
||||
protected UserConverter&MockObject $userConverter;
|
||||
protected ICacheFactory&MockObject $cacheFactory;
|
||||
protected RetryNotificationMapper&MockObject $retryNotificationMapper;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected RestrictionValidator&MockObject $restrictionValidator;
|
||||
protected ?CloudFederationProviderTalk $cloudFederationProvider = null;
|
||||
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
protected IAppManager|MockObject $appManager;
|
||||
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
|
||||
/** @var INotificationManager|MockObject */
|
||||
protected $notificationManager;
|
||||
|
||||
/** @var AttendeeMapper|MockObject */
|
||||
protected $attendeeMapper;
|
||||
|
||||
protected ProxyCacheMessageMapper|MockObject $proxyCacheMessageMapper;
|
||||
protected ProxyCacheMessageService|MockObject $proxyCacheMessageService;
|
||||
protected FederationChatNotifier|MockObject $federationChatNotifier;
|
||||
protected UserConverter|MockObject $userConverter;
|
||||
protected ICacheFactory|MockObject $cacheFactory;
|
||||
protected RetryNotificationMapper|MockObject $retryNotificationMapper;
|
||||
protected ITimeFactory|MockObject $timeFactory;
|
||||
protected RestrictionValidator|MockObject $restrictionValidator;
|
||||
protected ?BackendNotifier $backendNotifier = null;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -173,7 +153,7 @@ class FederationTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function testSendRemoteShareWithOwner() {
|
||||
public function testSendRemoteShareWithOwner(): void {
|
||||
$cloudShare = $this->createMock(ICloudFederationShare::class);
|
||||
|
||||
$providerId = '3';
|
||||
|
|
@ -276,7 +256,7 @@ class FederationTest extends TestCase {
|
|||
$this->backendNotifier->sendRemoteShare($providerId, $token, $shareWith, $sharedBy, $shareType, $room, $attendee);
|
||||
}
|
||||
|
||||
public function testReceiveRemoteShare() {
|
||||
public function testReceiveRemoteShare(): void {
|
||||
$providerId = '3';
|
||||
$token = 'abcdefghijklmno';
|
||||
$shareWith = 'test@remote.test.local';
|
||||
|
|
@ -400,7 +380,7 @@ class FederationTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function testSendAcceptNotification() {
|
||||
public function testSendAcceptNotification(): void {
|
||||
$remote = 'https://remote.test.local';
|
||||
$id = 50;
|
||||
$token = 'abcdefghijklmno';
|
||||
|
|
@ -447,7 +427,7 @@ class FederationTest extends TestCase {
|
|||
$this->assertTrue($success);
|
||||
}
|
||||
|
||||
public function testSendRejectNotification() {
|
||||
public function testSendRejectNotification(): void {
|
||||
$remote = 'https://remote.test.local';
|
||||
$id = 50;
|
||||
$token = 'abcdefghijklmno';
|
||||
|
|
|
|||
|
|
@ -36,10 +36,8 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class RestrictStartingCallsTest extends TestCase {
|
||||
/** @var IConfig|MockObject */
|
||||
protected $serverConfig;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
protected IConfig&MockObject $serverConfig;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected ?RestrictStartingCalls $listener = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -63,12 +61,6 @@ class RestrictStartingCallsTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCheckStartCallPermissions
|
||||
* @param int $roomType
|
||||
* @param string $roomObjectType
|
||||
* @param bool $canStart
|
||||
* @param bool $hasParticipants
|
||||
* @param bool $throws
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function testCheckStartCallPermissions(int $roomType, string $roomObjectType, bool $canStart, bool $hasParticipants, bool $throws): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use OCA\Talk\Model\Attendee;
|
|||
use OCA\Talk\Model\AttendeeMapper;
|
||||
use OCA\Talk\Participant;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IDBConnection;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +41,7 @@ class AttendeeMapperTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->attendeeMapper = new AttendeeMapper(
|
||||
\OC::$server->getDatabaseConnection()
|
||||
\OCP\Server::get(IDBConnection::class)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -355,10 +356,6 @@ class AttendeeMapperTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataModifyPermissions
|
||||
* @param array $attendees
|
||||
* @param string $mode
|
||||
* @param int $permission
|
||||
* @param array $expected
|
||||
*/
|
||||
public function testModifyPermissions(array $attendees, string $mode, int $permission, array $expected): void {
|
||||
$roomId = 12345678;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -59,47 +61,28 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class NotifierTest extends TestCase {
|
||||
/** @var IFactory|MockObject */
|
||||
protected $lFactory;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
/** @var Config|MockObject */
|
||||
protected $config;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var GuestManager|MockObject */
|
||||
protected $guestManager;
|
||||
/** @var IShareManager|MockObject */
|
||||
protected $shareManager;
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var AvatarService|MockObject */
|
||||
protected $avatarService;
|
||||
/** @var INotificationManager|MockObject */
|
||||
protected $notificationManager;
|
||||
/** @var CommentsManager|MockObject */
|
||||
protected $commentsManager;
|
||||
protected ProxyCacheMessageMapper|MockObject $proxyCacheMessageMapper;
|
||||
/** @var MessageParser|MockObject */
|
||||
protected $messageParser;
|
||||
/** @var IRootFolder|MockObject */
|
||||
protected $rootFolder;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var Definitions|MockObject */
|
||||
protected $definitions;
|
||||
protected IFactory&MockObject $lFactory;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected Config&MockObject $config;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected GuestManager&MockObject $guestManager;
|
||||
protected IShareManager&MockObject $shareManager;
|
||||
protected Manager&MockObject $manager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected AvatarService&MockObject $avatarService;
|
||||
protected INotificationManager&MockObject $notificationManager;
|
||||
protected CommentsManager&MockObject $commentsManager;
|
||||
protected ProxyCacheMessageMapper&MockObject $proxyCacheMessageMapper;
|
||||
protected MessageParser&MockObject $messageParser;
|
||||
protected IRootFolder&MockObject $rootFolder;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected Definitions&MockObject $definitions;
|
||||
protected AddressHandler&MockObject $addressHandler;
|
||||
protected BotServerMapper&MockObject $botServerMapper;
|
||||
protected FederationManager&MockObject $federationManager;
|
||||
protected ICloudIdManager&MockObject $cloudIdManager;
|
||||
protected ?Notifier $notifier = null;
|
||||
/** @var AddressHandler|MockObject */
|
||||
protected $addressHandler;
|
||||
/** @var BotServerMapper|MockObject */
|
||||
protected $botServerMapper;
|
||||
/** @var FederationManager|MockObject */
|
||||
protected $federationManager;
|
||||
protected ICloudIdManager|MockObject $cloudIdManager;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -160,12 +143,9 @@ class NotifierTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataPrepareOne2One
|
||||
* @param string $uid
|
||||
* @param string $displayName
|
||||
* @param string $parsedSubject
|
||||
*/
|
||||
public function testPrepareOne2One(string $uid, string $displayName, string $parsedSubject): void {
|
||||
/** @var INotification|MockObject $n */
|
||||
/** @var INotification&MockObject $n */
|
||||
$n = $this->createMock(INotification::class);
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$l->expects($this->any())
|
||||
|
|
@ -260,7 +240,7 @@ class NotifierTest extends TestCase {
|
|||
* @param string $displayName
|
||||
* @param string $parsedSubject
|
||||
*/
|
||||
public function testPreparingMultipleTimesOnlyGetsTheRoomOnce($uid, $displayName, $parsedSubject) {
|
||||
public function testPreparingMultipleTimesOnlyGetsTheRoomOnce($uid, $displayName, $parsedSubject): void {
|
||||
$numNotifications = 4;
|
||||
|
||||
$l = $this->createMock(IL10N::class);
|
||||
|
|
@ -319,7 +299,7 @@ class NotifierTest extends TestCase {
|
|||
}
|
||||
|
||||
public function getNotificationMock(string $parsedSubject, string $uid, string $displayName) {
|
||||
/** @var INotification|MockObject $n */
|
||||
/** @var INotification&MockObject $n */
|
||||
$n = $this->createMock(INotification::class);
|
||||
$n->expects($this->once())
|
||||
->method('setIcon')
|
||||
|
|
@ -369,7 +349,7 @@ class NotifierTest extends TestCase {
|
|||
return $n;
|
||||
}
|
||||
|
||||
public static function dataPrepareGroup() {
|
||||
public static function dataPrepareGroup(): array {
|
||||
return [
|
||||
[Room::TYPE_GROUP, 'admin', 'Admin', 'Group', 'Admin invited you to a group conversation: Group'],
|
||||
[Room::TYPE_PUBLIC, 'test', 'Test user', 'Public', 'Test user invited you to a group conversation: Public'],
|
||||
|
|
@ -378,15 +358,10 @@ class NotifierTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataPrepareGroup
|
||||
* @param int $type
|
||||
* @param string $uid
|
||||
* @param string $displayName
|
||||
* @param string $name
|
||||
* @param string $parsedSubject
|
||||
*/
|
||||
public function testPrepareGroup($type, $uid, $displayName, $name, $parsedSubject) {
|
||||
public function testPrepareGroup(int $type, string $uid, string $displayName, string $name, string $parsedSubject): void {
|
||||
$roomId = $type;
|
||||
/** @var INotification|MockObject $n */
|
||||
/** @var INotification&MockObject $n */
|
||||
$n = $this->createMock(INotification::class);
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$l->expects($this->any())
|
||||
|
|
@ -879,18 +854,9 @@ class NotifierTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataPrepareChatMessage
|
||||
* @param string $subject
|
||||
* @param int $roomType
|
||||
* @param array $subjectParameters
|
||||
* @param string $displayName
|
||||
* @param string $roomName
|
||||
* @param string $parsedSubject
|
||||
* @param array $richSubject
|
||||
* @param bool $deletedUser
|
||||
* @param null|string $guestName
|
||||
*/
|
||||
public function testPrepareChatMessage(string $subject, int $roomType, array $subjectParameters, $displayName, string $roomName, string $parsedSubject, array $richSubject, bool $deletedUser = false, ?string $guestName = null, bool $isPushNotification = false) {
|
||||
/** @var INotification|MockObject $notification */
|
||||
public function testPrepareChatMessage(string $subject, int $roomType, array $subjectParameters, ?string $displayName, string $roomName, string $parsedSubject, array $richSubject, bool $deletedUser = false, ?string $guestName = null, bool $isPushNotification = false): void {
|
||||
/** @var INotification&MockObject $notification */
|
||||
$notification = $this->createMock(INotification::class);
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$l->expects($this->any())
|
||||
|
|
@ -1073,7 +1039,7 @@ class NotifierTest extends TestCase {
|
|||
$this->assertEquals($notification, $this->notifier->prepare($notification, 'de'));
|
||||
}
|
||||
|
||||
public static function dataPrepareThrows() {
|
||||
public static function dataPrepareThrows(): array {
|
||||
return [
|
||||
['Incorrect app', 'invalid-app', null, null, null, null, null],
|
||||
'User can not use Talk' => [AlreadyProcessedException::class, 'spreed', true, null, null, null, null],
|
||||
|
|
@ -1088,18 +1054,9 @@ class NotifierTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataPrepareThrows
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $app
|
||||
* @param bool|null $isDisabledForUser
|
||||
* @param bool|null $validRoom
|
||||
* @param string|null $subject
|
||||
* @param array|null $params
|
||||
* @param string|null $objectType
|
||||
* @param string $token
|
||||
*/
|
||||
public function testPrepareThrows($message, $app, $isDisabledForUser, $validRoom, $subject, $params, $objectType, $token = 'roomToken') {
|
||||
/** @var INotification|MockObject $n */
|
||||
public function testPrepareThrows(string $message, string $app, ?bool $isDisabledForUser, ?bool $validRoom, ?string $subject, ?array $params, ?string $objectType, string $token = 'roomToken'): void {
|
||||
/** @var INotification&MockObject $n */
|
||||
$n = $this->createMock(INotification::class);
|
||||
$l = $this->createMock(IL10N::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018 Joachim Bauch <bauch@struktur.de>
|
||||
|
|
@ -75,18 +77,14 @@ class CustomBackendNotifier extends BackendNotifier {
|
|||
* @group DB
|
||||
*/
|
||||
class BackendNotifierTest extends TestCase {
|
||||
private ?Config $config = null;
|
||||
private ?ISecureRandom $secureRandom = null;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
private $urlGenerator;
|
||||
private ?CustomBackendNotifier $backendNotifier = null;
|
||||
|
||||
/** @var ParticipantService|MockObject */
|
||||
private $participantService;
|
||||
private ?Manager $manager = null;
|
||||
|
||||
private ?string $recordingSecret = null;
|
||||
private ?string $baseUrl = null;
|
||||
protected IURLGenerator&MockObject $urlGenerator;
|
||||
protected ParticipantService $participantService;
|
||||
protected ?CustomBackendNotifier $backendNotifier = null;
|
||||
protected ?Config $config = null;
|
||||
protected ?ISecureRandom $secureRandom = null;
|
||||
protected ?Manager $manager = null;
|
||||
protected ?string $recordingSecret = null;
|
||||
protected ?string $baseUrl = null;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -193,10 +191,10 @@ class BackendNotifierTest extends TestCase {
|
|||
$this->assertContainsEquals($message, $bodies, json_encode($bodies, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
public function testStart() {
|
||||
public function testStart(): void {
|
||||
$userId = 'testUser';
|
||||
|
||||
/** @var IUser|MockObject $testUser */
|
||||
/** @var IUser&MockObject $testUser */
|
||||
$testUser = $this->createMock(IUser::class);
|
||||
$testUser->expects($this->any())
|
||||
->method('getUID')
|
||||
|
|
@ -228,10 +226,10 @@ class BackendNotifierTest extends TestCase {
|
|||
]);
|
||||
}
|
||||
|
||||
public function testStop() {
|
||||
public function testStop(): void {
|
||||
$userId = 'testUser';
|
||||
|
||||
/** @var IUser|MockObject $testUser */
|
||||
/** @var IUser&MockObject $testUser */
|
||||
$testUser = $this->createMock(IUser::class);
|
||||
$testUser->expects($this->any())
|
||||
->method('getUID')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2022, Vitor Mattos <vitor@php.rio>
|
||||
*
|
||||
|
|
@ -43,21 +42,14 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class AvatarServiceTest extends TestCase {
|
||||
private AvatarService $service;
|
||||
/** @var IAppData|MockObject */
|
||||
private $appData;
|
||||
/** @var IL10N|MockObject */
|
||||
private $l;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
private $url;
|
||||
/** @var ISecureRandom|MockObject */
|
||||
private $random;
|
||||
/** @var RoomService|MockObject */
|
||||
private $roomService;
|
||||
/** @var IAvatarManager|MockObject */
|
||||
private $avatarManager;
|
||||
/** @var EmojiHelper|MockObject */
|
||||
private $emojiHelper;
|
||||
protected IAppData&MockObject $appData;
|
||||
protected IL10N&MockObject $l;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected ISecureRandom&MockObject $random;
|
||||
protected RoomService&MockObject $roomService;
|
||||
protected IAvatarManager&MockObject $avatarManager;
|
||||
protected EmojiHelper $emojiHelper;
|
||||
protected ?AvatarService $service = null;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -80,11 +72,19 @@ class AvatarServiceTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public static function dataGetAvatarVersion(): array {
|
||||
return [
|
||||
['', 'STRING WITH 8 CHARS'],
|
||||
['1', '1'],
|
||||
['1.png', '1'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetAvatarVersion
|
||||
*/
|
||||
public function testGetAvatarVersion(string $avatar, string $expected): void {
|
||||
/** @var Room|MockObject $room */
|
||||
/** @var Room&MockObject $room */
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->method('getAvatar')
|
||||
->willReturn($avatar);
|
||||
|
|
@ -96,14 +96,6 @@ class AvatarServiceTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public static function dataGetAvatarVersion(): array {
|
||||
return [
|
||||
['', 'STRING WITH 8 CHARS'],
|
||||
['1', '1'],
|
||||
['1.png', '1'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function dataGetFirstCombinedEmoji(): array {
|
||||
return [
|
||||
['👋 Hello', '👋'],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2023, Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -40,26 +39,16 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class BreakoutRoomServiceTest extends TestCase {
|
||||
private BreakoutRoomService $service;
|
||||
|
||||
/** @var Config|MockObject */
|
||||
private $config;
|
||||
/** @var Manager|MockObject */
|
||||
private $manager;
|
||||
/** @var RoomService|MockObject */
|
||||
private $roomService;
|
||||
/** @var ParticipantService|MockObject */
|
||||
private $participantService;
|
||||
/** @var ChatManager|MockObject */
|
||||
private $chatManager;
|
||||
/** @var INotificationManager|MockObject */
|
||||
private $notificationManager;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
private $dispatcher;
|
||||
/** @var IL10N|MockObject */
|
||||
private $l;
|
||||
protected Config&MockObject $config;
|
||||
protected Manager&MockObject $manager;
|
||||
protected RoomService&MockObject $roomService;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected ChatManager&MockObject $chatManager;
|
||||
protected INotificationManager&MockObject $notificationManager;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected IL10N&MockObject $l;
|
||||
protected BreakoutRoomService $service;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CertificateServiceTest extends TestCase {
|
|||
$this->service = new CertificateService($logger);
|
||||
}
|
||||
|
||||
public function testGetParsedTlsHost() {
|
||||
public function testGetParsedTlsHost(): void {
|
||||
$actual = $this->service->getParsedTlsHost("domain.com");
|
||||
$this->assertEquals($actual, "domain.com");
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\Federation\ICloudIdManager;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
|
@ -50,31 +51,20 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class ParticipantServiceTest extends TestCase {
|
||||
/** @var IConfig|MockObject */
|
||||
protected $serverConfig;
|
||||
/** @var Config|MockObject */
|
||||
protected $talkConfig;
|
||||
protected IConfig&MockObject $serverConfig;
|
||||
protected Config&MockObject $talkConfig;
|
||||
protected ?AttendeeMapper $attendeeMapper = null;
|
||||
protected ?SessionMapper $sessionMapper = null;
|
||||
/** @var SessionService|MockObject */
|
||||
protected $sessionService;
|
||||
/** @var ISecureRandom|MockObject */
|
||||
protected $secureRandom;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $dispatcher;
|
||||
/** @var IUserManager|MockObject */
|
||||
protected $userManager;
|
||||
protected ICloudIdManager|MockObject $cloudIdManager;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var MembershipService|MockObject */
|
||||
protected $membershipService;
|
||||
/** @var BackendNotifier|MockObject */
|
||||
protected $federationBackendNotifier;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $time;
|
||||
/** @var ICacheFactory|MockObject */
|
||||
protected $cacheFactory;
|
||||
protected SessionService&MockObject $sessionService;
|
||||
protected ISecureRandom&MockObject $secureRandom;
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected ICloudIdManager&MockObject $cloudIdManager;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected MembershipService&MockObject $membershipService;
|
||||
protected BackendNotifier&MockObject $federationBackendNotifier;
|
||||
protected ITimeFactory&MockObject $time;
|
||||
protected ICacheFactory&MockObject $cacheFactory;
|
||||
private ?ParticipantService $service = null;
|
||||
|
||||
|
||||
|
|
@ -83,8 +73,8 @@ class ParticipantServiceTest extends TestCase {
|
|||
|
||||
$this->serverConfig = $this->createMock(IConfig::class);
|
||||
$this->talkConfig = $this->createMock(Config::class);
|
||||
$this->attendeeMapper = new AttendeeMapper(\OC::$server->getDatabaseConnection());
|
||||
$this->sessionMapper = new SessionMapper(\OC::$server->getDatabaseConnection());
|
||||
$this->attendeeMapper = new AttendeeMapper(\OCP\Server::get(IDBConnection::class));
|
||||
$this->sessionMapper = new SessionMapper(\OCP\Server::get(IDBConnection::class));
|
||||
$this->sessionService = $this->createMock(SessionService::class);
|
||||
$this->secureRandom = $this->createMock(ISecureRandom::class);
|
||||
$this->dispatcher = $this->createMock(IEventDispatcher::class);
|
||||
|
|
@ -102,7 +92,7 @@ class ParticipantServiceTest extends TestCase {
|
|||
$this->sessionMapper,
|
||||
$this->sessionService,
|
||||
$this->secureRandom,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
$this->dispatcher,
|
||||
$this->userManager,
|
||||
$this->cloudIdManager,
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class ProxyCacheMessageServiceTest extends TestCase {
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected ?ProxyCacheMessageMapper $mapper = null;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
protected ITimeFactory|MockObject $timeFactory;
|
||||
protected ?ProxyCacheMessageService $service = null;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,40 +58,26 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class RecordingServiceTest extends TestCase {
|
||||
/** @var IMimeTypeDetector */
|
||||
private $mimeTypeDetector;
|
||||
/** @var ParticipantService|MockObject */
|
||||
private $participantService;
|
||||
/** @var IRootFolder|MockObject */
|
||||
private $rootFolder;
|
||||
/** @var Config|MockObject */
|
||||
private $config;
|
||||
/** @var IConfig|MockObject */
|
||||
private $serverConfig;
|
||||
/** @var IManager|MockObject */
|
||||
private $notificationManager;
|
||||
/** @var Manager|MockObject */
|
||||
private $roomManager;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
private $timeFactory;
|
||||
/** @var RoomService|MockObject */
|
||||
private $roomService;
|
||||
/** @var ShareManager|MockObject */
|
||||
private $shareManager;
|
||||
/** @var ChatManager|MockObject */
|
||||
private $chatManager;
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
/** @var BackendNotifier|MockObject */
|
||||
private $backendNotifier;
|
||||
private ISpeechToTextManager|MockObject $speechToTextManager;
|
||||
/** @var RecordingService */
|
||||
protected $recordingService;
|
||||
private IMimeTypeDetector $mimeTypeDetector;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected IRootFolder&MockObject $rootFolder;
|
||||
protected Config&MockObject $config;
|
||||
protected IConfig&MockObject $serverConfig;
|
||||
protected IManager&MockObject $notificationManager;
|
||||
protected Manager&MockObject $roomManager;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected RoomService&MockObject $roomService;
|
||||
protected ShareManager&MockObject $shareManager;
|
||||
protected ChatManager&MockObject $chatManager;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected BackendNotifier&MockObject $backendNotifier;
|
||||
protected ISpeechToTextManager&MockObject $speechToTextManager;
|
||||
protected RecordingService $recordingService;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class);
|
||||
$this->mimeTypeDetector = \OCP\Server::get(IMimeTypeDetector::class);
|
||||
$this->participantService = $this->createMock(ParticipantService::class);
|
||||
$this->rootFolder = $this->createMock(IRootFolder::class);
|
||||
$this->notificationManager = $this->createMock(IManager::class);
|
||||
|
|
@ -124,16 +110,6 @@ class RecordingServiceTest extends TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/** @dataProvider dataValidateFileFormat */
|
||||
public function testValidateFileFormat(string $fileName, string $fileRealPath, string $exceptionMessage): void {
|
||||
if ($exceptionMessage) {
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
} else {
|
||||
$this->expectNotToPerformAssertions();
|
||||
}
|
||||
$this->recordingService->validateFileFormat($fileName, $fileRealPath);
|
||||
}
|
||||
|
||||
public static function dataValidateFileFormat(): array {
|
||||
return [
|
||||
# file_invalid_path
|
||||
|
|
@ -151,22 +127,15 @@ class RecordingServiceTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetResourceFromFileArray
|
||||
* @dataProvider dataValidateFileFormat
|
||||
*/
|
||||
public function testGetResourceFromFileArray(array $file, $expected, string $exceptionMessage): void {
|
||||
public function testValidateFileFormat(string $fileName, string $fileRealPath, string $exceptionMessage): void {
|
||||
if ($exceptionMessage) {
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
} else {
|
||||
$this->expectNotToPerformAssertions();
|
||||
}
|
||||
|
||||
$room = $this->createMock(Room::class);
|
||||
$attendee = Attendee::fromRow([
|
||||
'actor_type' => Attendee::ACTOR_USERS,
|
||||
'actor_id' => 'participant1',
|
||||
]);
|
||||
$participant = new Participant($room, $attendee, null);
|
||||
|
||||
$actual = stream_get_contents($this->recordingService->getResourceFromFileArray($file, $room, $participant));
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->recordingService->validateFileFormat($fileName, $fileRealPath);
|
||||
}
|
||||
|
||||
public static function dataGetResourceFromFileArray(): array {
|
||||
|
|
@ -181,4 +150,23 @@ class RecordingServiceTest extends TestCase {
|
|||
[['error' => 0, 'tmp_name' => $fileWithContent], 'bla', ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetResourceFromFileArray
|
||||
*/
|
||||
public function testGetResourceFromFileArray(array $file, string $expected, string $exceptionMessage): void {
|
||||
if ($exceptionMessage) {
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
}
|
||||
|
||||
$room = $this->createMock(Room::class);
|
||||
$attendee = Attendee::fromRow([
|
||||
'actor_type' => Attendee::ACTOR_USERS,
|
||||
'actor_id' => 'participant1',
|
||||
]);
|
||||
$participant = new Participant($room, $attendee, null);
|
||||
|
||||
$actual = stream_get_contents($this->recordingService->getResourceFromFileArray($file, $room, $participant));
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,23 +52,15 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class RoomServiceTest extends TestCase {
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var ITimeFactory|MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IShareManager|MockObject */
|
||||
protected $shareManager;
|
||||
/** @var Config|MockObject */
|
||||
protected $config;
|
||||
/** @var IHasher|MockObject */
|
||||
protected $hasher;
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
protected $dispatcher;
|
||||
private ?RoomService $service = null;
|
||||
/** @var IJobList|MockObject */
|
||||
private IJobList $jobList;
|
||||
protected Manager&MockObject $manager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IShareManager&MockObject $shareManager;
|
||||
protected Config&MockObject $config;
|
||||
protected IHasher&MockObject $hasher;
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected IJobList&MockObject $jobList;
|
||||
protected ?RoomService $service = null;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -84,7 +76,7 @@ class RoomServiceTest extends TestCase {
|
|||
$this->service = new RoomService(
|
||||
$this->manager,
|
||||
$this->participantService,
|
||||
\OC::$server->get(IDBConnection::class),
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
$this->timeFactory,
|
||||
$this->shareManager,
|
||||
$this->config,
|
||||
|
|
@ -208,7 +200,6 @@ class RoomServiceTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateConversationInvalidNames
|
||||
* @param string $name
|
||||
*/
|
||||
public function testCreateConversationInvalidNames(string $name): void {
|
||||
$this->manager->expects($this->never())
|
||||
|
|
@ -230,7 +221,6 @@ class RoomServiceTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateConversationInvalidTypes
|
||||
* @param int $type
|
||||
*/
|
||||
public function testCreateConversationInvalidTypes(int $type): void {
|
||||
$this->manager->expects($this->never())
|
||||
|
|
@ -252,9 +242,6 @@ class RoomServiceTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateConversationInvalidObjects
|
||||
* @param string $type
|
||||
* @param string $id
|
||||
* @param string $exception
|
||||
*/
|
||||
public function testCreateConversationInvalidObjects(string $type, string $id, string $exception): void {
|
||||
$this->manager->expects($this->never())
|
||||
|
|
@ -275,11 +262,6 @@ class RoomServiceTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataCreateConversation
|
||||
* @param int $type
|
||||
* @param string $name
|
||||
* @param string $ownerId
|
||||
* @param string $objectType
|
||||
* @param string $objectId
|
||||
*/
|
||||
public function testCreateConversation(int $type, string $name, string $ownerId, string $objectType, string $objectId): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -328,8 +310,6 @@ class RoomServiceTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataPrepareConversationName
|
||||
* @param string $input
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testPrepareConversationName(string $input, string $expected): void {
|
||||
$this->assertSame($expected, $this->service->prepareConversationName($input));
|
||||
|
|
@ -356,7 +336,7 @@ class RoomServiceTest extends TestCase {
|
|||
$service = new RoomService(
|
||||
$this->manager,
|
||||
$this->participantService,
|
||||
\OC::$server->get(IDBConnection::class),
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
$this->timeFactory,
|
||||
$this->shareManager,
|
||||
$this->config,
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class SIPDialOutServiceTest extends TestCase {
|
||||
protected BackendNotifier|MockObject $backendNotifier;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
private ?SIPDialOutService $service = null;
|
||||
protected BackendNotifier&MockObject $backendNotifier;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected ?SIPDialOutService $service = null;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -40,27 +40,17 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class AdminSettingsTest extends TestCase {
|
||||
/** @var Config|MockObject */
|
||||
protected $talkConfig;
|
||||
/** @var IConfig|MockObject */
|
||||
protected $serverConfig;
|
||||
protected IAppConfig|MockObject $appConfig;
|
||||
/** @var CommandService|MockObject */
|
||||
protected $commandService;
|
||||
/** @var IInitialState|MockObject */
|
||||
protected $initialState;
|
||||
/** @var ICacheFactory|MockObject */
|
||||
protected $cacheFactory;
|
||||
/** @var IGroupManager|MockObject */
|
||||
protected $groupManager;
|
||||
/** @var MatterbridgeManager|MockObject */
|
||||
protected $matterbridgeManager;
|
||||
/** @var IUserSession|MockObject */
|
||||
protected $userSession;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l10n;
|
||||
/** @var IFactory|MockObject */
|
||||
protected $l10nFactory;
|
||||
protected Config&MockObject $talkConfig;
|
||||
protected IConfig&MockObject $serverConfig;
|
||||
protected IAppConfig&MockObject $appConfig;
|
||||
protected CommandService&MockObject $commandService;
|
||||
protected IInitialState&MockObject $initialState;
|
||||
protected ICacheFactory&MockObject $cacheFactory;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected MatterbridgeManager&MockObject $matterbridgeManager;
|
||||
protected IUserSession&MockObject $userSession;
|
||||
protected IL10N&MockObject $l10n;
|
||||
protected IFactory&MockObject $l10nFactory;
|
||||
protected ?AdminSettings $admin = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class SectionTest extends TestCase {
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
/** @var IL10N|MockObject */
|
||||
protected $l;
|
||||
protected IURLGenerator&MockObject $url;
|
||||
protected IL10N&MockObject $l;
|
||||
protected ?Section $admin = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Joachim Bauch (bauch@struktur.de)
|
||||
|
|
@ -40,17 +42,18 @@ use OCA\Talk\Signaling\Listener;
|
|||
use OCA\Talk\Signaling\Messages;
|
||||
use OCA\Talk\Webinary;
|
||||
use OCP\Comments\IComment;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class ListenerTest extends TestCase {
|
||||
protected ?BackendNotifier $backendNotifier = null;
|
||||
protected ?Manager $manager = null;
|
||||
protected ?ParticipantService $participantService = null;
|
||||
protected ?SessionService $sessionService = null;
|
||||
protected ?Listener $listener = null;
|
||||
protected BackendNotifier&MockObject $backendNotifier;
|
||||
protected Manager&MockObject $manager;
|
||||
protected ParticipantService&MockObject $participantService;
|
||||
protected SessionService&MockObject $sessionService;
|
||||
protected ?Listener $listener;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -175,10 +178,6 @@ class ListenerTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataRoomLobbyModified
|
||||
* @param int $newValue
|
||||
* @param int $oldValue
|
||||
* @param \DateTime|null $lobbyTimer
|
||||
* @param bool $timerReached
|
||||
*/
|
||||
public function testRoomLobbyModified(int $newValue, int $oldValue, ?\DateTime $lobbyTimer, bool $timerReached): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
|
|
@ -197,7 +196,7 @@ class ListenerTest extends TestCase {
|
|||
$this->listener->handle($event);
|
||||
}
|
||||
|
||||
public function testRoomLobbyRemoved() {
|
||||
public function testRoomLobbyRemoved(): void {
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$event = new LobbyModifiedEvent(
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class TalkSessionTest extends TestCase {
|
||||
/** @var ISession|MockObject */
|
||||
protected $session;
|
||||
|
||||
protected ISession&MockObject $session;
|
||||
protected ?TalkSession $talkSession = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -54,11 +52,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGet
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testGetSessionForRoom($sessionData, $expected) {
|
||||
public function testGetSessionForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-session')
|
||||
|
|
@ -68,11 +63,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataGet
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testGetPasswordForRoom($sessionData, $expected) {
|
||||
public function testGetPasswordForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-password')
|
||||
|
|
@ -91,11 +83,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSet
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testSetSessionForRoom($sessionData, $expected) {
|
||||
public function testSetSessionForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-session')
|
||||
|
|
@ -108,11 +97,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataSet
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testSetPasswordForRoom($sessionData, $expected) {
|
||||
public function testSetPasswordForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-password')
|
||||
|
|
@ -134,11 +120,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataRemove
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testRemoveSessionForRoom($sessionData, $expected) {
|
||||
public function testRemoveSessionForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-session')
|
||||
|
|
@ -151,11 +134,8 @@ class TalkSessionTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataRemove
|
||||
*
|
||||
* @param null|string $sessionData
|
||||
* @param null|string $expected
|
||||
*/
|
||||
public function testRemovePasswordForRoom($sessionData, $expected) {
|
||||
public function testRemovePasswordForRoom(?string $sessionData, ?string $expected): void {
|
||||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with('spreed-password')
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
timeoutForSmallTests="900"
|
||||
timeoutForMediumTests="900"
|
||||
timeoutForLargeTests="900"
|
||||
failOnDeprecation="true"
|
||||
failOnIncomplete="true"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
failOnEmptyTestSuite="true"
|
||||
failOnNotice="true"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
|
||||
cacheDirectory=".phpunit.result.cache">
|
||||
<testsuite name="Talk App Tests">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue