summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-04-12 12:46:48 +0200
committerJoas Schilling <coding@schilljs.com>2024-04-12 12:46:48 +0200
commitf28f7e6354cce3ea56047b2830957eea232e02a2 (patch)
treecb64e56faefbe4eed2da3268197265a2a85d927d
parent19937f6068274e311c13b1e4ff7e34ce5af1afca (diff)
fix(tests): Clean up unit test code
- static data providers - typed methods that consume data providers - type intersection with MockObject - move away from deprecated methods Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--tests/php/Activity/Provider/BaseTest.php51
-rw-r--r--tests/php/Activity/Provider/InvitationTest.php42
-rw-r--r--tests/php/Activity/SettingTest.php44
-rw-r--r--tests/php/BackgroundJob/CheckHostedSignalingServerTest.php29
-rw-r--r--tests/php/BackgroundJob/RemoveEmptyRoomsTest.php54
-rw-r--r--tests/php/CapabilitiesTest.php37
-rw-r--r--tests/php/Chat/AutoComplete/SearchPluginTest.php43
-rw-r--r--tests/php/Chat/AutoComplete/SorterTest.php12
-rw-r--r--tests/php/Chat/ChatManagerTest.php67
-rw-r--r--tests/php/Chat/Command/ExecutorTest.php32
-rw-r--r--tests/php/Chat/Command/ShellExecutorTest.php12
-rw-r--r--tests/php/Chat/NotifierTest.php157
-rw-r--r--tests/php/Chat/Parser/SystemMessageTest.php126
-rw-r--r--tests/php/Chat/Parser/UserMentionTest.php109
-rw-r--r--tests/php/Chat/SystemMessage/ListenerTest.php35
-rw-r--r--tests/php/Collaboration/Collaborators/RoomPluginTest.php16
-rw-r--r--tests/php/Collaboration/Reference/TalkReferenceProviderTest.php25
-rw-r--r--tests/php/Collaboration/Resources/ConversationProviderTest.php16
-rw-r--r--tests/php/Command/Signaling/AddTest.php34
-rw-r--r--tests/php/Command/Signaling/DeleteTest.php30
-rw-r--r--tests/php/Command/Signaling/ListCommandTest.php26
-rw-r--r--tests/php/Command/Stun/AddTest.php30
-rw-r--r--tests/php/Command/Stun/DeleteTest.php30
-rw-r--r--tests/php/Command/Stun/ListCommandTest.php26
-rw-r--r--tests/php/Command/Turn/AddTest.php54
-rw-r--r--tests/php/Command/Turn/DeleteTest.php34
-rw-r--r--tests/php/Command/Turn/ListCommandTest.php26
-rw-r--r--tests/php/ConfigTest.php29
-rw-r--r--tests/php/Controller/ChatControllerTest.php131
-rw-r--r--tests/php/Controller/SignalingControllerTest.php108
-rw-r--r--tests/php/EventDocumentationTest.php1
-rw-r--r--tests/php/Federation/FederationTest.php72
-rw-r--r--tests/php/Listener/RestrictStartingCallsTest.php12
-rw-r--r--tests/php/Model/AttendeeMapperTest.php7
-rw-r--r--tests/php/Notification/NotifierTest.php111
-rw-r--r--tests/php/Recording/BackendNotifierTest.php30
-rw-r--r--tests/php/Service/AvatarServiceTest.php42
-rw-r--r--tests/php/Service/BreakoutRoomServiceTest.php31
-rw-r--r--tests/php/Service/CertificateServiceTest.php2
-rw-r--r--tests/php/Service/ParticipantServiceTest.php42
-rw-r--r--tests/php/Service/ProxyCacheMessageServiceTest.php4
-rw-r--r--tests/php/Service/RecordingServiceTest.php92
-rw-r--r--tests/php/Service/RoomServiceTest.php42
-rw-r--r--tests/php/Service/SIPDialOutServiceTest.php6
-rw-r--r--tests/php/Settings/Admin/AdminSettingsTest.php32
-rw-r--r--tests/php/Settings/Admin/SectionTest.php6
-rw-r--r--tests/php/Signaling/ListenerTest.php19
-rw-r--r--tests/php/TalkSessionTest.php34
48 files changed, 789 insertions, 1261 deletions
diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php
index b80824bcb..71b9ccd70 100644
--- a/tests/php/Activity/Provider/BaseTest.php
+++ b/tests/php/Activity/Provider/BaseTest.php
@@ -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();
diff --git a/tests/php/Activity/Provider/InvitationTest.php b/tests/php/Activity/Provider/InvitationTest.php
index f6edb1c18..2d9a44e5a 100644
--- a/tests/php/Activity/Provider/InvitationTest.php
+++ b/tests/php/Activity/Provider/InvitationTest.php
@@ -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 {