diff options
author | Joas Schilling <coding@schilljs.com> | 2020-05-12 16:04:42 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-05-12 16:04:42 +0300 |
commit | 84d42604e60aa1c31ecf698dcc069f36c494148a (patch) | |
tree | 0c881194abad7aa1d6c103f1bad2b201b1c7acd4 /tests | |
parent | 851f76ecd2be9302cf7938e287929f9296b398d0 (diff) |
Run cs:fix
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
42 files changed, 135 insertions, 181 deletions
diff --git a/tests/acceptance/features/bootstrap/ChatAncestorSetter.php b/tests/acceptance/features/bootstrap/ChatAncestorSetter.php index 6842f5aa8..2ded22ba9 100644 --- a/tests/acceptance/features/bootstrap/ChatAncestorSetter.php +++ b/tests/acceptance/features/bootstrap/ChatAncestorSetter.php @@ -21,7 +21,6 @@ * */ -use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; /** @@ -62,5 +61,4 @@ trait ChatAncestorSetter { private function setChatAncestorForActor($chatAncestor, Actor $actor) { $this->chatContext->setChatAncestorForActor($chatAncestor, $actor); } - } diff --git a/tests/acceptance/features/bootstrap/ChatContext.php b/tests/acceptance/features/bootstrap/ChatContext.php index 0f377c95b..7af0256d8 100644 --- a/tests/acceptance/features/bootstrap/ChatContext.php +++ b/tests/acceptance/features/bootstrap/ChatContext.php @@ -44,7 +44,7 @@ class ChatContext implements Context, ActorAwareInterface { * @BeforeScenario */ public function initializeChatAncestors() { - $this->chatAncestorsByActor = array(); + $this->chatAncestorsByActor = []; $this->chatAncestor = null; } @@ -461,5 +461,4 @@ class ChatContext implements Context, ActorAwareInterface { public function iSeeThatTheMessageContainsAFormattedFilePreview($number) { PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::formattedFilePreviewInChatMessage($this->chatAncestor, $number), 10)); } - } diff --git a/tests/acceptance/features/bootstrap/ConversationInfoContext.php b/tests/acceptance/features/bootstrap/ConversationInfoContext.php index 8fac25417..23381244d 100644 --- a/tests/acceptance/features/bootstrap/ConversationInfoContext.php +++ b/tests/acceptance/features/bootstrap/ConversationInfoContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ConversationInfoContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -260,5 +259,4 @@ class ConversationInfoContext implements Context, ActorAwareInterface { $this->actor->find(self::roomModerationButton(), 10)->click(); } - } diff --git a/tests/acceptance/features/bootstrap/ConversationListContext.php b/tests/acceptance/features/bootstrap/ConversationListContext.php index 1d8e6d8d8..739ed42a6 100644 --- a/tests/acceptance/features/bootstrap/ConversationListContext.php +++ b/tests/acceptance/features/bootstrap/ConversationListContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ConversationListContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -176,7 +175,7 @@ class ConversationListContext implements Context, ActorAwareInterface { // It is assumed that the search input is empty, so no backspace or // delete keys are sent to remove the previous content like done in the // Selenium2 driver for Mink. - $webDriverElement->postValue(array('value' => array($value))); + $webDriverElement->postValue(['value' => [$value]]); } /** @@ -275,5 +274,4 @@ class ConversationListContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("The $conversation conversation is still active after $timeout seconds"); } } - } diff --git a/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php index caa638924..8c761a8bf 100644 --- a/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php @@ -25,7 +25,6 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; class FilesAppChatTabContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -97,5 +96,4 @@ class FilesAppChatTabContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("The chat was not shown yet in the chat tab after $timeout seconds"); } } - } diff --git a/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php index f64574ade..ee8b7f7ac 100644 --- a/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class FilesAppRoomSharingContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -34,5 +33,4 @@ class FilesAppRoomSharingContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::assertEquals( $this->actor->find(FilesAppSharingContext::sharedByLabel(), 10)->getText(), "Shared with you and the conversation $conversationName by $sharedByName"); } - } diff --git a/tests/acceptance/features/bootstrap/ParticipantListContext.php b/tests/acceptance/features/bootstrap/ParticipantListContext.php index 1907223e4..bf3585866 100644 --- a/tests/acceptance/features/bootstrap/ParticipantListContext.php +++ b/tests/acceptance/features/bootstrap/ParticipantListContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ParticipantListContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -91,7 +90,7 @@ class ParticipantListContext implements Context, ActorAwareInterface { * @Then I see that the number of participants shown in the list is :numberOfParticipants */ public function iSeeThatTheNumberOfParticipantsShownInTheListIs($numberOfParticipants) { - $numberOfParticipantsMatchCallback = function() use ($numberOfParticipants) { + $numberOfParticipantsMatchCallback = function () use ($numberOfParticipants) { try { return count($this->participantsListItems()) === intval($numberOfParticipants); } catch (NoSuchElementException $exception) { @@ -128,5 +127,4 @@ class ParticipantListContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("Participant $participantName is still marked as a moderator after $timeout seconds but it should be a normal participant instead"); } } - } diff --git a/tests/acceptance/features/bootstrap/PublicConversationContext.php b/tests/acceptance/features/bootstrap/PublicConversationContext.php index e13c9fd47..db9200ac0 100644 --- a/tests/acceptance/features/bootstrap/PublicConversationContext.php +++ b/tests/acceptance/features/bootstrap/PublicConversationContext.php @@ -25,7 +25,6 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; class PublicConversationContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -135,5 +134,4 @@ class PublicConversationContext implements Context, ActorAwareInterface { // it needs to be checked too that the chat view is shown. $this->chatContext->iSeeThatTheChatIsShownInTheMainView(); } - } diff --git a/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php b/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php index ad344d3d5..f4253cf31 100644 --- a/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php +++ b/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class PublicSharePasswordRequestContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -77,5 +76,4 @@ class PublicSharePasswordRequestContext implements Context, ActorAwareInterface } catch (NoSuchElementException $exception) { } } - } diff --git a/tests/acceptance/features/bootstrap/TalkAppContext.php b/tests/acceptance/features/bootstrap/TalkAppContext.php index 09f12076a..b583b4b3a 100644 --- a/tests/acceptance/features/bootstrap/TalkAppContext.php +++ b/tests/acceptance/features/bootstrap/TalkAppContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class TalkAppContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -162,5 +161,4 @@ class TalkAppContext implements Context, ActorAwareInterface { $this->iOpenTheTalkApp(); $this->iSeeThatTheCurrentPageIsTheTalkApp(); } - } diff --git a/tests/acceptance/features/bootstrap/TalkPublicShareContext.php b/tests/acceptance/features/bootstrap/TalkPublicShareContext.php index a25f33786..540d0d506 100644 --- a/tests/acceptance/features/bootstrap/TalkPublicShareContext.php +++ b/tests/acceptance/features/bootstrap/TalkPublicShareContext.php @@ -22,7 +22,6 @@ */ class TalkPublicShareContext extends PublicShareContext { - use ChatAncestorSetter; /** @@ -73,5 +72,4 @@ class TalkPublicShareContext extends PublicShareContext { } catch (NoSuchElementException $exception) { } } - } diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index e7fda0f14..db78038ff 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -134,7 +134,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $rooms = $this->getDataFromResponse($this->response); - $rooms = array_filter($rooms, function($room) { + $rooms = array_filter($rooms, function ($room) { return $room['type'] !== 4; }); @@ -144,8 +144,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { } Assert::assertCount(count($formData->getHash()), $rooms, 'Room count does not match'); - Assert::assertEquals($formData->getHash(), array_map(function($room, $expectedRoom) { - $participantNames = array_map(function($participant) { + Assert::assertEquals($formData->getHash(), array_map(function ($room, $expectedRoom) { + $participantNames = array_map(function ($participant) { return $participant['name']; }, $room['participants']); @@ -200,7 +200,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $rooms = $this->getDataFromResponse($this->response); - $rooms = array_filter($rooms, function($room) { + $rooms = array_filter($rooms, function ($room) { return $room['type'] !== 4; }); @@ -534,7 +534,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { public function userSetsLobbyStateForRoomTo($user, $identifier, $lobbyStateString, $statusCode) { if ($lobbyStateString === 'no lobby') { $lobbyState = 0; - } else if ($lobbyStateString === 'non moderators') { + } elseif ($lobbyStateString === 'non moderators') { $lobbyState = 1; } else { Assert::fail('Invalid lobby state'); @@ -776,7 +776,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $actual = $this->getDataFromResponse($this->response); $messages = []; - array_map(function(array $message) use (&$messages) { + array_map(function (array $message) use (&$messages) { // Filter out system messages if ($message['systemMessage'] === '') { $messages[] = $message; @@ -804,7 +804,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $messages[$i]['messageParameters'] = 'IGNORE'; } } - Assert::assertEquals($formData->getHash(), array_map(function($message) use($includeParents, $includeReferenceId) { + Assert::assertEquals($formData->getHash(), array_map(function ($message) use ($includeParents, $includeReferenceId) { $data = [ 'room' => self::$tokenToIdentifier[$message['token']], 'actorType' => $message['actorType'], @@ -838,7 +838,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->assertStatusCode($this->response, $statusCode); $messages = $this->getDataFromResponse($this->response); - $messages = array_filter($messages, function(array $message) { + $messages = array_filter($messages, function (array $message) { return $message['systemMessage'] !== ''; }); @@ -854,7 +854,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { } Assert::assertCount(count($formData->getHash()), $messages, 'Message count does not match'); - Assert::assertEquals($formData->getHash(), array_map(function($message) { + Assert::assertEquals($formData->getHash(), array_map(function ($message) { return [ 'room' => self::$tokenToIdentifier[$message['token']], 'actorType' => (string) $message['actorType'], @@ -1176,13 +1176,13 @@ class FeatureContext implements Context, SnippetAcceptingContext { $options = ['cookies' => $this->getUserCookieJar($this->currentUser)]; if ($this->currentUser === 'admin') { $options['auth'] = ['admin', 'admin']; - } else if (strpos($this->currentUser, 'guest') !== 0) { + } elseif (strpos($this->currentUser, 'guest') !== 0) { $options['auth'] = [$this->currentUser, '123456']; } if ($body instanceof TableNode) { $fd = $body->getRowsHash(); $options['form_params'] = $fd; - } else if (is_array($body)) { + } elseif (is_array($body)) { $options['form_params'] = $body; } diff --git a/tests/integration/features/bootstrap/SharingContext.php b/tests/integration/features/bootstrap/SharingContext.php index b15223b5e..5d20b46f3 100644 --- a/tests/integration/features/bootstrap/SharingContext.php +++ b/tests/integration/features/bootstrap/SharingContext.php @@ -493,7 +493,7 @@ class SharingContext implements Context { public function transferingOwnershipFromTo(string $user1, string $user2) { $args = ['files:transfer-ownership', $user1, $user2]; - $args = array_map(function($arg) { + $args = array_map(function ($arg) { return escapeshellarg($arg); }, $args); $args[] = '--no-ansi'; @@ -576,7 +576,7 @@ class SharingContext implements Context { $returnedShare = (array) $returnedShare; $returnedShare = $returnedShare['element']; if (is_array($returnedShare)) { - usort($returnedShare, static function($share1, $share2) { + usort($returnedShare, static function ($share1, $share2) { return (int) $share1->id - (int) $share2->id; }); } @@ -712,7 +712,7 @@ class SharingContext implements Context { public function theResponseContainsAShareTypesFilesPropertyForWith(string $path, TableNode $table = null) { $response = json_decode($this->response->getBody()); - $fileForPath = array_filter($response->files, function($file) use ($path) { + $fileForPath = array_filter($response->files, function ($file) use ($path) { $filePath = $file->path . (substr($file->path, -1) === '/'? '': '/'); return ($filePath . $file->name) === $path; }); @@ -759,7 +759,7 @@ class SharingContext implements Context { if ($body instanceof TableNode) { foreach ($body->getRowsHash() as $key => $value) { - if ($key === 'expireDate' && $value !== 'invalid date'){ + if ($key === 'expireDate' && $value !== 'invalid date') { $value = date('Y-m-d', strtotime($value)); } $parameters[] = $key . '=' . $value; @@ -792,7 +792,7 @@ class SharingContext implements Context { ]; if ($body instanceof TableNode) { $fd = $body->getRowsHash(); - if (array_key_exists('expireDate', $fd)){ + if (array_key_exists('expireDate', $fd)) { $fd['expireDate'] = date('Y-m-d', strtotime($fd['expireDate'])); } $options['form_params'] = $fd; @@ -934,7 +934,7 @@ class SharingContext implements Context { * @param string $contentExpected * @param \SimpleXMLElement $returnedShare */ - private function assertFieldIsInReturnedShare(string $field, string $contentExpected, \SimpleXMLElement $returnedShare){ + private function assertFieldIsInReturnedShare(string $field, string $contentExpected, \SimpleXMLElement $returnedShare) { if ($contentExpected === 'IGNORE') { return; } @@ -943,17 +943,17 @@ class SharingContext implements Context { \PHPUnit\Framework\Assert::fail("$field was not found in response"); } - if ($field === 'expiration' && !empty($contentExpected)){ + if ($field === 'expiration' && !empty($contentExpected)) { $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; } if ($contentExpected === 'A_NUMBER') { \PHPUnit\Framework\Assert::assertTrue(is_numeric((string)$returnedShare->$field), "Field '$field' is not a number: " . $returnedShare->$field); - } else if ($contentExpected === 'A_TOKEN') { + } elseif ($contentExpected === 'A_TOKEN') { // A token is composed by 15 characters from // ISecureRandom::CHAR_HUMAN_READABLE. \PHPUnit\Framework\Assert::assertRegExp('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token"); - } else if (strpos($contentExpected, 'REGEXP ') === 0) { + } elseif (strpos($contentExpected, 'REGEXP ') === 0) { \PHPUnit\Framework\Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match"); } else { \PHPUnit\Framework\Assert::assertEquals($contentExpected, (string)$returnedShare->$field, "Field '$field' does not match"); @@ -1006,5 +1006,4 @@ class SharingContext implements Context { } return $sharees; } - } diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php index b5537d59a..8a14f21e7 100644 --- a/tests/integration/spreedcheats/lib/Controller/ApiController.php +++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php @@ -50,7 +50,6 @@ class ApiController extends OCSController { * @return DataResponse */ public function resetSpreed() { - $query = $this->db->getQueryBuilder(); $query->delete('talk_signaling')->execute(); diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php index 9ed72bc2e..f38e8058a 100644 --- a/tests/php/Activity/Provider/BaseTest.php +++ b/tests/php/Activity/Provider/BaseTest.php @@ -21,14 +21,12 @@ namespace OCA\Talk\Tests\php\Activity\Provider; - use OCA\Talk\Activity\Provider\Base; use OCA\Talk\Config; use OCA\Talk\Manager; use OCA\Talk\Room; use OCP\Activity\IEvent; use OCP\Activity\IManager; -use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; diff --git a/tests/php/Activity/Provider/InvitationTest.php b/tests/php/Activity/Provider/InvitationTest.php index a06cd30d5..9f382c51f 100644 --- a/tests/php/Activity/Provider/InvitationTest.php +++ b/tests/php/Activity/Provider/InvitationTest.php @@ -21,7 +21,6 @@ namespace OCA\Talk\Tests\php\Activity\Provider; - use OCA\Talk\Activity\Provider\Invitation; use OCA\Talk\Config; use OCA\Talk\Exceptions\RoomNotFoundException; @@ -146,7 +145,7 @@ class InvitationTest extends TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -221,5 +220,4 @@ class InvitationTest extends TestCase { $provider->parse($lang, $event); } - } diff --git a/tests/php/Activity/SettingTest.php b/tests/php/Activity/SettingTest.php index 5ec1356c9..730e0c5b3 100644 --- a/tests/php/Activity/SettingTest.php +++ b/tests/php/Activity/SettingTest.php @@ -26,7 +26,6 @@ use OCP\Activity\ISetting; use Test\TestCase; class SettingTest extends TestCase { - public function dataSettings() { return [ [Setting::class], diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index eea12ab44..4a47cc075 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Chat/AutoComplete/SearchPluginTest.php b/tests/php/Chat/AutoComplete/SearchPluginTest.php index d1b753af5..67e094f2f 100644 --- a/tests/php/Chat/AutoComplete/SearchPluginTest.php +++ b/tests/php/Chat/AutoComplete/SearchPluginTest.php @@ -61,7 +61,7 @@ class SearchPluginTest extends \Test\TestCase { $this->l = $this->createMock(IL10N::class); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); } @@ -129,16 +129,16 @@ class SearchPluginTest extends \Test\TestCase { $plugin->expects($this->once()) ->method('searchUsers') ->with('fo', ['123', 'foo', 'bar'], $result) - ->willReturnCallback(function($search, $users, $result) { - array_map(function($user) { + ->willReturnCallback(function ($search, $users, $result) { + array_map(function ($user) { $this->assertIsString($user); }, $users); }); $plugin->expects($this->once()) ->method('searchGuests') ->with('fo', $this->anything(), $result) - ->willReturnCallback(function($search, $guests, $result) { - array_map(function($guest) { + ->willReturnCallback(function ($search, $guests, $result) { + array_map(function ($guest) { $this->assertIsString($guest); $this->assertSame(40, strlen($guest)); }, $guests); @@ -175,7 +175,7 @@ class SearchPluginTest extends \Test\TestCase { public function testSearchUsers($search, array $userIds, array $userNames, array $expected, array $expectedExact) { $result = $this->createMock(ISearchResult::class); - $userMap = array_map(function($userData) { + $userMap = array_map(function ($userData) { return [$userData['uid'], $this->createUserMock($userData)]; }, $userNames); @@ -190,7 +190,7 @@ class SearchPluginTest extends \Test\TestCase { $plugin = $this->getPlugin(['createResult']); $plugin->expects($this->any()) ->method('createResult') - ->willReturnCallback(function($type, $uid, $name) { + ->willReturnCallback(function ($type, $uid, $name) { return [$uid => $name]; }); @@ -229,7 +229,7 @@ class SearchPluginTest extends \Test\TestCase { $plugin = $this->getPlugin(['createGuestResult']); $plugin->expects($this->any()) ->method('createGuestResult') - ->willReturnCallback(function($hash, $name) { + ->willReturnCallback(function ($hash, $name) { return [$hash => $name]; }); diff --git a/tests/php/Chat/AutoComplete/SorterTest.php b/tests/php/Chat/AutoComplete/SorterTest.php index 84abcb6dd..2fffedd90 100644 --- a/tests/php/Chat/AutoComplete/SorterTest.php +++ b/tests/php/Chat/AutoComplete/SorterTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php index e531a1c2e..f6d220fbc 100644 --- a/tests/php/Chat/ChatManagerTest.php +++ b/tests/php/Chat/ChatManagerTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -315,7 +316,6 @@ class ChatManagerTest extends TestCase { } public function testDeleteMessages() { - $chat = $this->createMock(Room::class); $chat->expects($this->any()) ->method('getId') @@ -331,5 +331,4 @@ class ChatManagerTest extends TestCase { $this->chatManager->deleteMessages($chat); } - } diff --git a/tests/php/Chat/Command/ExecutorTest.php b/tests/php/Chat/Command/ExecutorTest.php index f797e61a4..e4ce4ea37 100644 --- a/tests/php/Chat/Command/ExecutorTest.php +++ b/tests/php/Chat/Command/ExecutorTest.php @@ -34,7 +34,6 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; class ExecutorTest extends TestCase { @@ -174,6 +173,5 @@ class ExecutorTest extends TestCase { ->willReturn($output); $this->assertSame($output, $this->executor->execShell($room, $message, $command, $arguments)); - } } diff --git a/tests/php/Chat/Command/ShellExecutorTest.php b/tests/php/Chat/Command/ShellExecutorTest.php index 41a258b84..7286c5a24 100644 --- a/tests/php/Chat/Command/ShellExecutorTest.php +++ b/tests/php/Chat/Command/ShellExecutorTest.php @@ -27,7 +27,6 @@ use OCA\Talk\Chat\Command\ShellExecutor; use Test\TestCase; class ShellExecutorTest extends TestCase { - public function dataExecShellRun(): array { return [ ['admin', 'token', 'echo {ARGUMENTS}', '$PATH', '$PATH'], @@ -71,7 +70,6 @@ class ShellExecutorTest extends TestCase { public function testExecShellRun(?string $actorId, string $roomToken, string $cmd, string $arguments, string $output): void { $executor = new ShellExecutor(); $this->assertSame($output, $executor->execShell($cmd, $arguments, $roomToken, $actorId)); - } public function dataExecShell(): array { diff --git a/tests/php/Chat/NotifierTest.php b/tests/php/Chat/NotifierTest.php index d382e0951..8c5827e4a 100644 --- a/tests/php/Chat/NotifierTest.php +++ b/tests/php/Chat/NotifierTest.php @@ -61,7 +61,7 @@ class NotifierTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->userManager ->method('userExists') - ->willReturnCallback(function($userId) { + ->willReturnCallback(function ($userId) { return $userId !== 'unknownUser'; }); @@ -84,7 +84,7 @@ class NotifierTest extends TestCase { $mentionMatches = []; preg_match_all('/@([a-zA-Z0-9]+)/', $message, $mentionMatches); - $mentions = array_map(function($mentionMatch) { + $mentions = array_map(function ($mentionMatch) { return [ 'type' => 'user', 'id' => $mentionMatch ]; }, $mentionMatches[1]); @@ -551,5 +551,4 @@ class NotifierTest extends TestCase { $this->notifier->removePendingNotificationsForRoom($room); } - } diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 4c895c901..955cfaf3c 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -76,12 +76,12 @@ class SystemMessageTest extends TestCase { $this->l = $this->createMock(IL10N::class); $this->l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); $this->l->expects($this->any()) ->method('n') - ->will($this->returnCallback(function($singular, $plural, $count, $parameters = []) { + ->will($this->returnCallback(function ($singular, $plural, $count, $parameters = []) { $text = $count === 1 ? $singular : $plural; return vsprintf(str_replace('%n', $count, $text), $parameters); })); @@ -656,7 +656,6 @@ class SystemMessageTest extends TestCase { } public function testGetFileFromShareThrows() { - $this->shareProvider->expects($this->once()) ->method('getShareById') ->with('23') @@ -928,7 +927,7 @@ class SystemMessageTest extends TestCase { $parser->expects($this->any()) ->method('getUser') - ->willReturnCallback(function($user) { + ->willReturnCallback(function ($user) { return ['data' => $user]; }); diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php index 2e9f7a8a3..a25c13641 100644 --- a/tests/php/Chat/Parser/UserMentionTest.php +++ b/tests/php/Chat/Parser/UserMentionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -377,7 +378,7 @@ class UserMentionTest extends \Test\TestCase { ->willThrowException(new ParticipantNotFoundException()); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -417,7 +418,7 @@ class UserMentionTest extends \Test\TestCase { ->willThrowException(new ParticipantNotFoundException()); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -457,7 +458,7 @@ class UserMentionTest extends \Test\TestCase { ->willReturn('Name'); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -477,5 +478,4 @@ class UserMentionTest extends \Test\TestCase { $this->assertEquals('Mention to {mention-guest1}, and again {mention-guest1}', $chatMessage->getMessage()); $this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters()); } - } diff --git a/tests/php/Collaboration/Collaborators/RoomPluginTest.php b/tests/php/Collaboration/Collaborators/RoomPluginTest.php index 4598fd1d5..424fbefcb 100644 --- a/tests/php/Collaboration/Collaborators/RoomPluginTest.php +++ b/tests/php/Collaboration/Collaborators/RoomPluginTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -241,7 +242,7 @@ class RoomPluginTest extends \Test\TestCase { ->method('addResultSet') ->with( $this->callback( - function(SearchResultType $searchResultType) { + function (SearchResultType $searchResultType) { return $searchResultType->getLabel() === 'rooms'; } ), @@ -253,5 +254,4 @@ class RoomPluginTest extends \Test\TestCase { $this->assertSame($expectedHasMoreResults, $hasMoreResults); } - } diff --git a/tests/php/Collaboration/Resources/ConversationProviderTest.php b/tests/php/Collaboration/Resources/ConversationProviderTest.php index a8c7c4211..c76c5a752 100644 --- a/tests/php/Collaboration/Resources/ConversationProviderTest.php +++ b/tests/php/Collaboration/Resources/ConversationProviderTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,14 +23,12 @@ declare(strict_types=1); namespace OCA\Talk\Tests\php\Collaboration\Resources; -use OCA\Talk\Collaboration\Collaborators\RoomPlugin; use OCA\Talk\Collaboration\Resources\ConversationProvider; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Manager; use OCA\Talk\Participant; use OCA\Talk\Room; -use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Resources\IResource; use OCP\Collaboration\Resources\ResourceException; use OCP\IURLGenerator; diff --git a/tests/php/Command/Signaling/AddTest.php b/tests/php/Command/Signaling/AddTest.php index c1abd4d24..d3038d24c 100644 --- a/tests/php/Command/Signaling/AddTest.php +++ b/tests/php/Command/Signaling/AddTest.php @@ -55,10 +55,10 @@ class AddTest extends TestCase { public function testServerEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return ''; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); @@ -77,10 +77,10 @@ class AddTest extends TestCase { public function testSecretEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return ''; } throw new \Exception(); @@ -99,10 +99,10 @@ class AddTest extends TestCase { public function testAddServerToEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); @@ -138,10 +138,10 @@ class AddTest extends TestCase { public function testAddServerToNonEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling2.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); diff --git a/tests/php/Command/Turn/AddTest.php b/tests/php/Command/Turn/AddTest.php index 211a2fccc..3401add75 100644 --- a/tests/php/Command/Turn/AddTest.php +++ b/tests/php/Command/Turn/AddTest.php @@ -55,19 +55,19 @@ class AddTest extends TestCase { public function testServerEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return ''; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -83,19 +83,19 @@ class AddTest extends TestCase { public function testSecretEmpty() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return ''; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -111,19 +111,19 @@ class AddTest extends TestCase { public function testGenerateSecret() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return null; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return true; } throw new \Exception(); @@ -161,19 +161,19 @@ class AddTest extends TestCase { public function testSecretAndGenerateSecretOptions() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return true; } throw new \Exception(); @@ -189,19 +189,19 @@ class AddTest extends TestCase { public function testInvalidProtocolsString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'invalid-protocol'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -217,19 +217,19 @@ class AddTest extends TestCase { public function testAddServerToEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -259,19 +259,19 @@ class AddTest extends TestCase { public function testAddServerToNonEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn2.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret-2'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -312,19 +312,19 @@ class AddTest extends TestCase { public function testServerSanitization() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'https://turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); diff --git a/tests/php/Command/Turn/DeleteTest.php b/tests/php/Command/Turn/DeleteTest.php index ca795ff49..3617e3341 100644 --- a/tests/php/Command/Turn/DeleteTest.php +++ b/tests/php/Command/Turn/DeleteTest.php @@ -55,10 +55,10 @@ class DeleteTest extends TestCase { public function testDeleteIfEmpty() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); @@ -83,10 +83,10 @@ class DeleteTest extends TestCase { public function testDelete() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn2.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); @@ -123,10 +123,10 @@ class DeleteTest extends TestCase { public function testNothingToDelete() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn4.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); diff --git a/tests/php/ConfigTest.php b/tests/php/ConfigTest.php index c79be1e29..bda84ac5f 100644 --- a/tests/php/ConfigTest.php +++ b/tests/php/ConfigTest.php @@ -29,7 +29,6 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class ConfigTest extends TestCase { - public function testGetStunServer() { $servers = [ 'stun1.example.com:443', @@ -244,5 +243,4 @@ class ConfigTest extends TestCase { self::invokePrivate($helper, 'getWebSocketDomainForSignalingServer', [$url]) ); } - } diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php index 6833125cc..6da163417 100644 --- a/tests/php/Controller/ChatControllerTest.php +++ b/tests/php/Controller/ChatControllerTest.php @@ -27,10 +27,7 @@ use OCA\Talk\Chat\AutoComplete\SearchPlugin; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Controller\ChatController; -use OCA\Talk\Exceptions\ParticipantNotFoundException; -use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\GuestManager; -use OCA\Talk\Manager; use OCA\Talk\Model\Message; use OCA\Talk\Participant; use OCA\Talk\Room; @@ -104,7 +101,7 @@ class ChatControllerTest extends TestCase { // Verifies that the difference of the given DateTime and now is at most // five seconds, and that it uses the UTC time zone. - $this->newMessageDateTimeConstraint = $this->callback(function(\DateTime $dateTime) { + $this->newMessageDateTimeConstraint = $this->callback(function (\DateTime $dateTime) { return abs((new \DateTime())->getTimestamp() - $dateTime->getTimestamp()) <= 5 && (new \DateTimeZone('UTC'))->getName() === $dateTime->getTimezone()->getName(); }); @@ -610,7 +607,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -676,7 +673,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -745,7 +742,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -822,7 +819,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment3, $this->l], [$this->room, $participant, $comment4, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -935,7 +932,7 @@ class ChatControllerTest extends TestCase { ]], [ ['id' => 'foo', 'label' => 'Foo Bar', 'source' => 'users'], ['id' => 'foobar', 'label' => 'FooBar', 'source' => 'users'], - ]], + ]], ]; } diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php index 7e72e27c7..83a9bb0ec 100644 --- a/tests/php/Controller/SignalingControllerTest.php +++ b/tests/php/Controller/SignalingControllerTest.php @@ -44,10 +44,8 @@ use OCP\IUserManager; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; class CustomInputSignalingController extends SignalingController { - private $inputStream; public function setInputStream($data) { @@ -57,7 +55,6 @@ class CustomInputSignalingController extends SignalingController { protected function getInputStream(): string { return $this->inputStream; } - } /** @@ -658,7 +655,7 @@ class SignalingControllerTest extends \Test\TestCase { } public function testBackendRoomSessionFromEvent() { - $this->dispatcher->addListener(SignalingController::EVENT_BACKEND_SIGNALING_ROOMS, static function(SignalingEvent $event) { + $this->dispatcher->addListener(SignalingController::EVENT_BACKEND_SIGNALING_ROOMS, static function (SignalingEvent $event) { $room = $event->getRoom(); $event->setSession([ 'foo' => 'bar', @@ -939,5 +936,4 @@ class SignalingControllerTest extends \Test\TestCase { $participant = $room->getParticipant($this->userId); $this->assertEquals($newSessionId, $participant->getSessionId()); } - } diff --git a/tests/php/Files/UtilTest.php b/tests/php/Files/UtilTest.php index 9e332144b..4b6eb2dac 100644 --- a/tests/php/Files/UtilTest.php +++ b/tests/php/Files/UtilTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -35,7 +36,6 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class UtilTest extends TestCase { - public function createNodeMock(string $type, bool $instanceOfGroupFolderStorage = false) { $node = $this->createMock(Node::class); $node->expects($this->once()) @@ -68,7 +68,7 @@ class UtilTest extends TestCase { ['28', 'admin6', [ $this->createNodeMock(FileInfo::TYPE_FOLDER), $this->createNodeMock(FileInfo::TYPE_FILE, true) - ], 1], + ], 1], ]; } @@ -81,7 +81,6 @@ class UtilTest extends TestCase { * @param bool|int $hasReturn */ public function testGetGroupFolderNode(string $fileId, string $userId, array $nodes, $return): void { - $userFolder = $this->createMock(Folder::class); $userFolder->expects($this->once()) ->method('getById') diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php index 89eb5a114..9c74fd66c 100644 --- a/tests/php/Notification/NotifierTest.php +++ b/tests/php/Notification/NotifierTest.php @@ -121,7 +121,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -231,7 +231,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -589,7 +589,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -641,7 +641,7 @@ class NotifierTest extends \Test\TestCase { ->method('get') ->with($subjectParameters['userId']) ->willReturn($user); - } else if ($subjectParameters['userType'] === 'users' && $deletedUser) { + } elseif ($subjectParameters['userType'] === 'users' && $deletedUser) { $user->expects($this->never()) ->method('getDisplayName'); $this->userManager->expects($this->at(1)) @@ -774,7 +774,7 @@ class NotifierTest extends \Test\TestCase { if ($validRoom === null) { $this->manager->expects($this->never()) ->method('getRoomByToken'); - } else if ($validRoom === true) { + } elseif ($validRoom === true) { $room = $this->createMock(Room::class); $room->expects($this->never()) ->method('getType'); @@ -785,7 +785,7 @@ class NotifierTest extends \Test\TestCase { ->method('getRoomByToken') ->with('roomToken') ->willReturn($room); - } else if ($validRoom === false) { + } elseif ($validRoom === false) { $n->expects($this->exactly(2)) ->method('getObjectId') ->willReturn('roomToken'); diff --git a/tests/php/RoomTest.php b/tests/php/RoomTest.php index e240c0db2..e3a3a3846 100644 --- a/tests/php/RoomTest.php +++ b/tests/php/RoomTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Peter Edens <petere@conceiva.com> @@ -34,21 +35,19 @@ use OCP\Security\ISecureRandom; use Test\TestCase; class RoomTest extends TestCase { - public function testVerifyPassword() { $dispatcher = new EventDispatcher( new \Symfony\Component\EventDispatcher\EventDispatcher(), \OC::$server, $this->createMock(ILogger::class) ); - $dispatcher->addListener(Room::EVENT_PASSWORD_VERIFY, static function(VerifyRoomPasswordEvent $event) { + $dispatcher->addListener(Room::EVENT_PASSWORD_VERIFY, static function (VerifyRoomPasswordEvent $event) { $password = $event->getPassword(); if ($password === '1234') { $event->setIsPasswordValid(true); $event->setRedirectUrl(''); - } - else { + } else { $event->setIsPasswordValid(false); $event->setRedirectUrl('https://test'); } diff --git a/tests/php/Settings/Admin/AdminSettingsTest.php b/tests/php/Settings/Admin/AdminSettingsTest.php index c3594d182..f9122461e 100644 --- a/tests/php/Settings/Admin/AdminSettingsTest.php +++ b/tests/php/Settings/Admin/AdminSettingsTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Settings/Admin/SectionTest.php b/tests/php/Settings/Admin/SectionTest.php index cb664ddd1..a156cdcea 100644 --- a/tests/php/Settings/Admin/SectionTest.php +++ b/tests/php/Settings/Admin/SectionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php index fda09243b..fcd990292 100644 --- a/tests/php/Signaling/BackendNotifierTest.php +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -43,10 +43,8 @@ use OCP\IUserManager; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; class CustomBackendNotifier extends BackendNotifier { - private $requests = []; public function getRequests(): array { @@ -63,7 +61,6 @@ class CustomBackendNotifier extends BackendNotifier { 'params' => $params, ]; } - } /** @@ -131,7 +128,7 @@ class BackendNotifierTest extends \Test\TestCase { $this->app->register(); $this->originalBackendNotifier = $this->app->getContainer()->query(BackendNotifier::class); - $this->app->getContainer()->registerService(BackendNotifier::class, function() { + $this->app->getContainer()->registerService(BackendNotifier::class, function () { return $this->controller; }); @@ -154,7 +151,7 @@ class BackendNotifierTest extends \Test\TestCase { public function tearDown(): void { $config = \OC::$server->getConfig(); $config->deleteAppValue('spreed', 'signaling_servers'); - $this->app->getContainer()->registerService(BackendNotifier::class, function() { + $this->app->getContainer()->registerService(BackendNotifier::class, function () { return $this->originalBackendNotifier; }); parent::tearDown(); @@ -196,7 +193,7 @@ class BackendNotifierTest extends \Test\TestCase { ]); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); @@ -235,7 +232,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->removeUser($testUser, Room::PARTICIPANT_REMOVED); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -263,7 +260,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setName('Test room'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -288,7 +285,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setPassword('password'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -313,7 +310,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setType(Room::GROUP_CALL); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -338,7 +335,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setReadOnly(Room::READ_ONLY); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -363,7 +360,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setLobby(Webinary::LOBBY_NON_MODERATORS, null); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -391,7 +388,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->deleteRoom(); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -415,7 +412,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($participant, Participant::FLAG_IN_CALL | Participant::FLAG_WITH_AUDIO | Participant::FLAG_WITH_VIDEO); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -449,7 +446,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($guestParticipant, Participant::FLAG_IN_CALL); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -486,7 +483,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($participant, Participant::FLAG_DISCONNECTED); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -515,7 +512,7 @@ class BackendNotifierTest extends \Test\TestCase { } public function testRoomPropertiesEvent(): void { - $listener = static function(SignalingRoomPropertiesEvent $event) { + $listener = static function (SignalingRoomPropertiesEvent $event) { $room = $event->getRoom(); $event->setProperty('foo', 'bar'); $event->setProperty('room', $room->getToken()); @@ -528,7 +525,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setName('Test room'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); @@ -562,7 +559,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($participant, Participant::MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -596,7 +593,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($guestParticipant, Participant::GUEST_MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -638,7 +635,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($notJoinedParticipant, Participant::MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -675,7 +672,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($participant, Participant::USER); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -720,7 +717,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($guestParticipant, Participant::GUEST); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -760,5 +757,4 @@ class BackendNotifierTest extends \Test\TestCase { ], ], $bodies); } - } diff --git a/tests/php/TalkSessionTest.php b/tests/php/TalkSessionTest.php index 38ed812e6..5f183760e 100644 --- a/tests/php/TalkSessionTest.php +++ b/tests/php/TalkSessionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/tests/php/bootstrap.php b/tests/php/bootstrap.php index 424fc6606..71e40d9c8 100644 --- a/tests/php/bootstrap.php +++ b/tests/php/bootstrap.php @@ -25,7 +25,7 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../../lib/base.php'; \OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests'); \OC_App::loadApp('spreed'); -if(!class_exists('\PHPUnit\Framework\TestCase')) { +if (!class_exists('\PHPUnit\Framework\TestCase')) { require_once('PHPUnit/Autoload.php'); } OC_Hook::clear(); |