From 9549ca8c91f9ca6726fe1f3b2bb1aa3ec594d1c8 Mon Sep 17 00:00:00 2001 From: Artem Henvald Date: Sat, 25 May 2024 10:26:59 +0300 Subject: [PATCH] Fix response parser (#38) --- Model/ChannelsCommand.php | 8 ++++ Model/HistoryCommand.php | 8 ++++ Model/InfoCommand.php | 8 ++++ Model/PresenceCommand.php | 8 ++++ Model/PresenceStatsCommand.php | 8 ++++ Model/ResultableCommandInterface.php | 6 +++ Service/ResponseProcessor.php | 2 +- .../Argument/ArgumentChannelTraitTest.php | 10 +++-- .../Argument/ArgumentChannelsTraitTest.php | 4 +- .../Argument/ArgumentDataTraitTest.php | 7 +++- .../Argument/ArgumentUserTraitTest.php | 4 +- Tests/Command/BroadcastCommandTest.php | 10 +++-- Tests/Command/ChannelsCommandTest.php | 16 +++++--- Tests/Command/DisconnectCommandTest.php | 16 +++++--- Tests/Command/HistoryCommandTest.php | 10 +++-- Tests/Command/HistoryRemoveCommandTest.php | 7 +++- Tests/Command/InfoCommandTest.php | 13 ++++-- .../Option/OptionBase64DataTraitTest.php | 7 +++- .../Option/OptionBase64InfoTraitTest.php | 7 +++- Tests/Command/Option/OptionDataTraitTest.php | 7 +++- .../Option/OptionDisconnectCodeTraitTest.php | 7 +++- .../OptionDisconnectReasonTraitTest.php | 4 +- Tests/Command/Option/OptionEpochTraitTest.php | 4 +- .../Option/OptionExpireAtTraitTest.php | 10 +++-- .../Command/Option/OptionExpiredTraitTest.php | 4 +- Tests/Command/Option/OptionInfoTraitTest.php | 7 +++- Tests/Command/Option/OptionLimitTraitTest.php | 10 +++-- .../Command/Option/OptionOffsetTraitTest.php | 10 +++-- .../Command/Option/OptionReverseTraitTest.php | 4 +- .../Option/OptionSkipHistoryTraitTest.php | 4 +- Tests/Command/Option/OptionTagsTraitTest.php | 13 ++++-- Tests/Command/PresenceCommandTest.php | 10 +++-- Tests/Command/PresenceStatsCommandTest.php | 7 +++- Tests/Command/PublishCommandTest.php | 10 +++-- Tests/Command/RefreshCommandTest.php | 10 +++-- Tests/Command/SubscribeCommandTest.php | 10 +++-- Tests/Command/UnsubscribeCommandTest.php | 10 +++-- Tests/DataCollector/CommandCollectorTest.php | 7 +++- .../Compiler/RegisterCentrifugoPassTest.php | 7 +++- .../FreshCentrifugoExtensionTest.php | 7 +++- .../CentrifugoErrorExceptionTest.php | 10 +++-- Tests/Exception/CentrifugoExceptionTest.php | 7 +++- .../InvalidArgumentExceptionTest.php | 4 +- Tests/Exception/LogicExceptionTest.php | 4 +- .../UnexpectedValueExceptionTest.php | 4 +- Tests/FreshCentrifugoBundleTest.php | 4 +- Tests/Logger/CommandHistoryLoggerTest.php | 10 +++-- Tests/Model/BatchRequestTest.php | 19 ++++++--- Tests/Model/BroadcastCommandTest.php | 13 ++++-- Tests/Model/ChannelsCommandTest.php | 20 ++++++++-- Tests/Model/DisconnectCommandTest.php | 13 ++++-- Tests/Model/DisconnectTest.php | 4 +- Tests/Model/HistoryCommandTest.php | 28 ++++++++++--- Tests/Model/HistoryRemoveCommandTest.php | 10 +++-- Tests/Model/InfoCommandTest.php | 19 +++++++-- Tests/Model/PresenceCommandTest.php | 18 +++++++-- Tests/Model/PresenceStatsCommandTest.php | 18 +++++++-- Tests/Model/PublishCommandTest.php | 13 ++++-- Tests/Model/RefreshCommandTest.php | 13 ++++-- Tests/Model/StreamPositionTest.php | 4 +- Tests/Model/SubscribeCommandTest.php | 16 +++++--- Tests/Model/UnsubscribeCommandTest.php | 13 ++++-- Tests/Service/CentrifugoCheckerTest.php | 28 ++++++++----- Tests/Service/CentrifugoTest.php | 40 +++++++++++++------ .../PrivateChannelAuthenticatorTest.php | 30 +++++++------- .../Credentials/CredentialsGeneratorTest.php | 13 ++++-- Tests/Service/FakeCentrifugoTest.php | 4 +- Tests/Service/Jwt/JwtGeneratorTest.php | 19 ++++++--- Tests/Service/ResponseProcessorTest.php | 32 +++++++++------ Tests/Token/JwtPayloadForChannelTest.php | 10 +++-- .../Token/JwtPayloadForPrivateChannelTest.php | 10 +++-- Tests/Token/JwtPayloadTest.php | 10 +++-- composer.json | 6 +-- phpunit.xml.dist | 2 +- 74 files changed, 568 insertions(+), 221 deletions(-) diff --git a/Model/ChannelsCommand.php b/Model/ChannelsCommand.php index cdafc73..a940384 100755 --- a/Model/ChannelsCommand.php +++ b/Model/ChannelsCommand.php @@ -32,4 +32,12 @@ public function __construct(string $pattern = null) parent::__construct(Method::CHANNELS, $params); } + + /** + * {@inheritdoc} + */ + public function processResponse(array $data): array + { + return $data; + } } diff --git a/Model/HistoryCommand.php b/Model/HistoryCommand.php index e37ff26..712a35e 100755 --- a/Model/HistoryCommand.php +++ b/Model/HistoryCommand.php @@ -53,4 +53,12 @@ public function __construct(protected readonly string $channel, bool $reverse = parent::__construct(Method::HISTORY, $params); } + + /** + * {@inheritdoc} + */ + public function processResponse(array $data): array + { + return $data['result']; + } } diff --git a/Model/InfoCommand.php b/Model/InfoCommand.php index 978db7e..5b7da8c 100755 --- a/Model/InfoCommand.php +++ b/Model/InfoCommand.php @@ -26,4 +26,12 @@ public function __construct() { parent::__construct(Method::INFO, []); } + + /** + * {@inheritdoc} + */ + public function processResponse(array $data): array + { + return $data['result']; + } } diff --git a/Model/PresenceCommand.php b/Model/PresenceCommand.php index d5bb33f..b8e39ff 100755 --- a/Model/PresenceCommand.php +++ b/Model/PresenceCommand.php @@ -33,4 +33,12 @@ public function __construct(protected readonly string $channel) ] ); } + + /** + * {@inheritdoc} + */ + public function processResponse(array $data): array + { + return $data['result']['presence']; + } } diff --git a/Model/PresenceStatsCommand.php b/Model/PresenceStatsCommand.php index 5e0cbf8..b45ec8c 100755 --- a/Model/PresenceStatsCommand.php +++ b/Model/PresenceStatsCommand.php @@ -33,4 +33,12 @@ public function __construct(protected readonly string $channel) ] ); } + + /** + * {@inheritdoc} + */ + public function processResponse(array $data): array + { + return $data['result']; + } } diff --git a/Model/ResultableCommandInterface.php b/Model/ResultableCommandInterface.php index db3fe57..776c9af 100755 --- a/Model/ResultableCommandInterface.php +++ b/Model/ResultableCommandInterface.php @@ -19,4 +19,10 @@ */ interface ResultableCommandInterface extends CommandInterface { + /** + * @param array $data + * + * @return array + */ + public function processResponse(array $data): array; } diff --git a/Service/ResponseProcessor.php b/Service/ResponseProcessor.php index 3c1c0dd..37be873 100755 --- a/Service/ResponseProcessor.php +++ b/Service/ResponseProcessor.php @@ -129,7 +129,7 @@ private function decodeAndProcessResponseResult(CommandInterface $command, Respo $result = $data; $successfulCommand = false; } elseif ($command instanceof ResultableCommandInterface) { - $result = $data[$command->getMethod()->value]; + $result = $command->processResponse($data); } if ($this->profilerEnabled) { diff --git a/Tests/Command/Argument/ArgumentChannelTraitTest.php b/Tests/Command/Argument/ArgumentChannelTraitTest.php index 9b92255..437f33c 100755 --- a/Tests/Command/Argument/ArgumentChannelTraitTest.php +++ b/Tests/Command/Argument/ArgumentChannelTraitTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Exception\InvalidArgumentException as CentrifugoInvalidArgumentException; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -64,7 +65,8 @@ protected function tearDown(): void ); } - public function testInvalidChannelName(): void + #[Test] + public function invalidChannelName(): void { $this->centrifugoChecker ->expects(self::once()) @@ -89,7 +91,8 @@ public function testInvalidChannelName(): void ); } - public function testChannelNameIsNotString(): void + #[Test] + public function channelNameIsNotString(): void { $this->centrifugoChecker ->expects(self::never()) @@ -112,7 +115,8 @@ public function testChannelNameIsNotString(): void ); } - public function testChannelNameIsMissed(): void + #[Test] + public function channelNameIsMissed(): void { $this->centrifugoChecker ->expects(self::never()) diff --git a/Tests/Command/Argument/ArgumentChannelsTraitTest.php b/Tests/Command/Argument/ArgumentChannelsTraitTest.php index e7e47d1..ab7204f 100755 --- a/Tests/Command/Argument/ArgumentChannelsTraitTest.php +++ b/Tests/Command/Argument/ArgumentChannelsTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\BroadcastCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testInvalidChannelName(): void + #[Test] + public function invalidChannelName(): void { $this->centrifugoChecker ->expects(self::once()) diff --git a/Tests/Command/Argument/ArgumentDataTraitTest.php b/Tests/Command/Argument/ArgumentDataTraitTest.php index 1e4efd5..7889f55 100755 --- a/Tests/Command/Argument/ArgumentDataTraitTest.php +++ b/Tests/Command/Argument/ArgumentDataTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\BroadcastCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testDataIsNotValidJson(): void + #[Test] + public function dataIsNotValidJson(): void { $this->centrifugo ->expects(self::never()) @@ -82,7 +84,8 @@ public function testDataIsNotValidJson(): void ); } - public function testDataIsNotString(): void + #[Test] + public function dataIsNotString(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/Argument/ArgumentUserTraitTest.php b/Tests/Command/Argument/ArgumentUserTraitTest.php index 76fafcf..6101f56 100755 --- a/Tests/Command/Argument/ArgumentUserTraitTest.php +++ b/Tests/Command/Argument/ArgumentUserTraitTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\DisconnectCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -57,7 +58,8 @@ protected function tearDown(): void ); } - public function testInvalidUser(): void + #[Test] + public function invalidUser(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/BroadcastCommandTest.php b/Tests/Command/BroadcastCommandTest.php index 44fa87b..a764650 100755 --- a/Tests/Command/BroadcastCommandTest.php +++ b/Tests/Command/BroadcastCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\BroadcastCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -83,7 +85,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -107,7 +110,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/ChannelsCommandTest.php b/Tests/Command/ChannelsCommandTest.php index 741135c..b5c38ed 100755 --- a/Tests/Command/ChannelsCommandTest.php +++ b/Tests/Command/ChannelsCommandTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\ChannelsCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -56,7 +57,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithoutPattern(): void + #[Test] + public function successfulExecutionWithoutPattern(): void { $this->centrifugo ->expects(self::once()) @@ -73,7 +75,8 @@ public function testSuccessfulExecutionWithoutPattern(): void self::assertStringContainsString('Total Channels: 2', $output); } - public function testSuccessfulExecutionWithPattern(): void + #[Test] + public function successfulExecutionWithPattern(): void { $this->centrifugo ->expects(self::once()) @@ -94,7 +97,8 @@ public function testSuccessfulExecutionWithPattern(): void self::assertStringContainsString('Total Channels: 1', $output); } - public function testNoData(): void + #[Test] + public function noData(): void { $this->centrifugo ->expects(self::once()) @@ -109,7 +113,8 @@ public function testNoData(): void self::assertStringContainsString('NO DATA', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) @@ -124,7 +129,8 @@ public function testException(): void self::assertStringContainsString('test', $output); } - public function testAutocomplete(): void + #[Test] + public function autocomplete(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/DisconnectCommandTest.php b/Tests/Command/DisconnectCommandTest.php index e90bc71..631e6db 100755 --- a/Tests/Command/DisconnectCommandTest.php +++ b/Tests/Command/DisconnectCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\DisconnectCommand; use Fresh\CentrifugoBundle\Model\Disconnect; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -58,7 +59,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -78,7 +80,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -103,7 +106,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testExceptionForMissingDisconnectCode(): void + #[Test] + public function exceptionForMissingDisconnectCode(): void { $this->centrifugo ->expects(self::never()) @@ -129,7 +133,8 @@ public function testExceptionForMissingDisconnectCode(): void self::assertStringContainsString('DONE', $output); } - public function testExceptionForMissingDisconnectReason(): void + #[Test] + public function exceptionForMissingDisconnectReason(): void { $this->centrifugo ->expects(self::never()) @@ -155,7 +160,8 @@ public function testExceptionForMissingDisconnectReason(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/HistoryCommandTest.php b/Tests/Command/HistoryCommandTest.php index ad68528..0b1acea 100755 --- a/Tests/Command/HistoryCommandTest.php +++ b/Tests/Command/HistoryCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\StreamPosition; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -106,7 +108,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('Epoch: test', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -153,7 +156,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('Epoch: test', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/HistoryRemoveCommandTest.php b/Tests/Command/HistoryRemoveCommandTest.php index 98f1554..004302d 100755 --- a/Tests/Command/HistoryRemoveCommandTest.php +++ b/Tests/Command/HistoryRemoveCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\HistoryRemoveCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecution(): void + #[Test] + public function successfulExecution(): void { $this->centrifugo ->expects(self::once()) @@ -82,7 +84,8 @@ public function testSuccessfulExecution(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/InfoCommandTest.php b/Tests/Command/InfoCommandTest.php index 50008f1..084e84c 100755 --- a/Tests/Command/InfoCommandTest.php +++ b/Tests/Command/InfoCommandTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\InfoCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -56,7 +57,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecution(): void + #[Test] + public function successfulExecution(): void { $this->centrifugo ->expects(self::once()) @@ -90,7 +92,8 @@ public function testSuccessfulExecution(): void self::assertStringContainsString(' └ process.virtual.memory_max_bytes: -1', $output); } - public function testNoData(): void + #[Test] + public function noData(): void { $this->centrifugo ->expects(self::once()) @@ -105,7 +108,8 @@ public function testNoData(): void self::assertStringContainsString('NO DATA', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) @@ -120,7 +124,8 @@ public function testException(): void self::assertStringContainsString('test', $output); } - public function testUnexpectedValueException(): void + #[Test] + public function unexpectedValueException(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionBase64DataTraitTest.php b/Tests/Command/Option/OptionBase64DataTraitTest.php index 8b02bf5..4e0a347 100755 --- a/Tests/Command/Option/OptionBase64DataTraitTest.php +++ b/Tests/Command/Option/OptionBase64DataTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PublishCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testOptionIsNotValidBase64(): void + #[Test] + public function optionIsNotValidBase64(): void { $this->centrifugo ->expects(self::never()) @@ -83,7 +85,8 @@ public function testOptionIsNotValidBase64(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionBase64InfoTraitTest.php b/Tests/Command/Option/OptionBase64InfoTraitTest.php index 04ff450..53f004e 100755 --- a/Tests/Command/Option/OptionBase64InfoTraitTest.php +++ b/Tests/Command/Option/OptionBase64InfoTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\SubscribeCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testOptionIsNotValidBase64(): void + #[Test] + public function optionIsNotValidBase64(): void { $this->centrifugo ->expects(self::never()) @@ -83,7 +85,8 @@ public function testOptionIsNotValidBase64(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionDataTraitTest.php b/Tests/Command/Option/OptionDataTraitTest.php index 66284e1..2207396 100755 --- a/Tests/Command/Option/OptionDataTraitTest.php +++ b/Tests/Command/Option/OptionDataTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\SubscribeCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testDataIsNotValidJson(): void + #[Test] + public function dataIsNotValidJson(): void { $this->centrifugo ->expects(self::never()) @@ -83,7 +85,8 @@ public function testDataIsNotValidJson(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionDisconnectCodeTraitTest.php b/Tests/Command/Option/OptionDisconnectCodeTraitTest.php index d8b26a9..7c5c202 100755 --- a/Tests/Command/Option/OptionDisconnectCodeTraitTest.php +++ b/Tests/Command/Option/OptionDisconnectCodeTraitTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\DisconnectCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -57,7 +58,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) @@ -74,7 +76,8 @@ public function testValidOption(): void ); } - public function testInvalidOption(): void + #[Test] + public function invalidOption(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/Option/OptionDisconnectReasonTraitTest.php b/Tests/Command/Option/OptionDisconnectReasonTraitTest.php index cc9be44..1acfe04 100755 --- a/Tests/Command/Option/OptionDisconnectReasonTraitTest.php +++ b/Tests/Command/Option/OptionDisconnectReasonTraitTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\DisconnectCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -56,7 +57,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionEpochTraitTest.php b/Tests/Command/Option/OptionEpochTraitTest.php index edf077e..cedd998 100755 --- a/Tests/Command/Option/OptionEpochTraitTest.php +++ b/Tests/Command/Option/OptionEpochTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\HistoryCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionExpireAtTraitTest.php b/Tests/Command/Option/OptionExpireAtTraitTest.php index ebc08d6..1115089 100755 --- a/Tests/Command/Option/OptionExpireAtTraitTest.php +++ b/Tests/Command/Option/OptionExpireAtTraitTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\RefreshCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -57,7 +58,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) @@ -73,7 +75,8 @@ public function testValidOption(): void ); } - public function testZeroValue(): void + #[Test] + public function zeroValue(): void { $this->centrifugo ->expects(self::never()) @@ -92,7 +95,8 @@ public function testZeroValue(): void ); } - public function testNonStringValue(): void + #[Test] + public function nonStringValue(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/Option/OptionExpiredTraitTest.php b/Tests/Command/Option/OptionExpiredTraitTest.php index cbaf9df..7f3c810 100755 --- a/Tests/Command/Option/OptionExpiredTraitTest.php +++ b/Tests/Command/Option/OptionExpiredTraitTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\RefreshCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -56,7 +57,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionInfoTraitTest.php b/Tests/Command/Option/OptionInfoTraitTest.php index 117aed2..eb7c39c 100755 --- a/Tests/Command/Option/OptionInfoTraitTest.php +++ b/Tests/Command/Option/OptionInfoTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\SubscribeCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testDataIsNotValidJson(): void + #[Test] + public function dataIsNotValidJson(): void { $this->centrifugo ->expects(self::never()) @@ -83,7 +85,8 @@ public function testDataIsNotValidJson(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionLimitTraitTest.php b/Tests/Command/Option/OptionLimitTraitTest.php index 81b67c7..12070ee 100755 --- a/Tests/Command/Option/OptionLimitTraitTest.php +++ b/Tests/Command/Option/OptionLimitTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\HistoryCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) @@ -79,7 +81,8 @@ public function testValidOption(): void ); } - public function testZeroValue(): void + #[Test] + public function zeroValue(): void { $this->centrifugo ->expects(self::never()) @@ -98,7 +101,8 @@ public function testZeroValue(): void ); } - public function testNonStringValue(): void + #[Test] + public function nonStringValue(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/Option/OptionOffsetTraitTest.php b/Tests/Command/Option/OptionOffsetTraitTest.php index f8196b1..d7f7d09 100755 --- a/Tests/Command/Option/OptionOffsetTraitTest.php +++ b/Tests/Command/Option/OptionOffsetTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\HistoryCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) @@ -79,7 +81,8 @@ public function testValidOption(): void ); } - public function testZeroValue(): void + #[Test] + public function zeroValue(): void { $this->centrifugo ->expects(self::never()) @@ -98,7 +101,8 @@ public function testZeroValue(): void ); } - public function testNonStringValue(): void + #[Test] + public function nonStringValue(): void { $this->centrifugo ->expects(self::never()) diff --git a/Tests/Command/Option/OptionReverseTraitTest.php b/Tests/Command/Option/OptionReverseTraitTest.php index d4c0e9c..46ed0d6 100755 --- a/Tests/Command/Option/OptionReverseTraitTest.php +++ b/Tests/Command/Option/OptionReverseTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\HistoryCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionSkipHistoryTraitTest.php b/Tests/Command/Option/OptionSkipHistoryTraitTest.php index a68d76c..9c4c4a4 100755 --- a/Tests/Command/Option/OptionSkipHistoryTraitTest.php +++ b/Tests/Command/Option/OptionSkipHistoryTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PublishCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testValidOption(): void + #[Test] + public function validOption(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/Option/OptionTagsTraitTest.php b/Tests/Command/Option/OptionTagsTraitTest.php index 9ccd933..894fedf 100755 --- a/Tests/Command/Option/OptionTagsTraitTest.php +++ b/Tests/Command/Option/OptionTagsTraitTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PublishCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testTagsIsNotValidJson(): void + #[Test] + public function tagsIsNotValidJson(): void { $this->centrifugo ->expects(self::never()) @@ -83,7 +85,8 @@ public function testTagsIsNotValidJson(): void ); } - public function testTagsIsNotArray(): void + #[Test] + public function tagsIsNotArray(): void { $this->centrifugo ->expects(self::never()) @@ -103,7 +106,8 @@ public function testTagsIsNotArray(): void ); } - public function testTagValueIsNotString(): void + #[Test] + public function tagValueIsNotString(): void { $this->centrifugo ->expects(self::never()) @@ -123,7 +127,8 @@ public function testTagValueIsNotString(): void ); } - public function testValidTags(): void + #[Test] + public function validTags(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/PresenceCommandTest.php b/Tests/Command/PresenceCommandTest.php index 3d4d5e3..3ddbc86 100755 --- a/Tests/Command/PresenceCommandTest.php +++ b/Tests/Command/PresenceCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PresenceCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecution(): void + #[Test] + public function successfulExecution(): void { $this->centrifugo ->expects(self::once()) @@ -103,7 +105,8 @@ public function testSuccessfulExecution(): void self::assertStringContainsString('"username": "user1@test.com"', $output); } - public function testNoData(): void + #[Test] + public function noData(): void { $this->centrifugo ->expects(self::once()) @@ -124,7 +127,8 @@ public function testNoData(): void self::assertStringContainsString('NO DATA', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/PresenceStatsCommandTest.php b/Tests/Command/PresenceStatsCommandTest.php index 58e2063..9c108e8 100755 --- a/Tests/Command/PresenceStatsCommandTest.php +++ b/Tests/Command/PresenceStatsCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PresenceStatsCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecution(): void + #[Test] + public function successfulExecution(): void { $this->centrifugo ->expects(self::once()) @@ -90,7 +92,8 @@ public function testSuccessfulExecution(): void self::assertStringContainsString('Total number of unique users in channel: 1', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/PublishCommandTest.php b/Tests/Command/PublishCommandTest.php index d4d1ff0..4d4215b 100755 --- a/Tests/Command/PublishCommandTest.php +++ b/Tests/Command/PublishCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\PublishCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -83,7 +85,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -107,7 +110,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/RefreshCommandTest.php b/Tests/Command/RefreshCommandTest.php index 1ad8c95..8d49601 100755 --- a/Tests/Command/RefreshCommandTest.php +++ b/Tests/Command/RefreshCommandTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Command\RefreshCommand; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -56,7 +57,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -76,7 +78,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -100,7 +103,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/SubscribeCommandTest.php b/Tests/Command/SubscribeCommandTest.php index b89c08a..d8d58ac 100755 --- a/Tests/Command/SubscribeCommandTest.php +++ b/Tests/Command/SubscribeCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\StreamPosition; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -63,7 +64,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -84,7 +86,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -113,7 +116,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/Command/UnsubscribeCommandTest.php b/Tests/Command/UnsubscribeCommandTest.php index 84e14bf..6373a82 100755 --- a/Tests/Command/UnsubscribeCommandTest.php +++ b/Tests/Command/UnsubscribeCommandTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Command\UnsubscribeCommand; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; @@ -62,7 +63,8 @@ protected function tearDown(): void ); } - public function testSuccessfulExecutionWithRequiredParameters(): void + #[Test] + public function successfulExecutionWithRequiredParameters(): void { $this->centrifugo ->expects(self::once()) @@ -83,7 +85,8 @@ public function testSuccessfulExecutionWithRequiredParameters(): void self::assertStringContainsString('DONE', $output); } - public function testSuccessfulExecutionWithAllParameters(): void + #[Test] + public function successfulExecutionWithAllParameters(): void { $this->centrifugo ->expects(self::once()) @@ -106,7 +109,8 @@ public function testSuccessfulExecutionWithAllParameters(): void self::assertStringContainsString('DONE', $output); } - public function testException(): void + #[Test] + public function exception(): void { $this->centrifugo ->expects(self::once()) diff --git a/Tests/DataCollector/CommandCollectorTest.php b/Tests/DataCollector/CommandCollectorTest.php index cca17b1..e21222b 100755 --- a/Tests/DataCollector/CommandCollectorTest.php +++ b/Tests/DataCollector/CommandCollectorTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\DataCollector\CentrifugoCollector; use Fresh\CentrifugoBundle\Logger\CommandHistoryLogger; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -45,7 +46,8 @@ protected function tearDown(): void ); } - public function testConstructor(): void + #[Test] + public function constructor(): void { self::assertEquals(0, $this->centrifugoCollector->getCommandsCount()); self::assertEquals(0, $this->centrifugoCollector->getRequestsCount()); @@ -55,7 +57,8 @@ public function testConstructor(): void self::assertSame('centrifugo', $this->centrifugoCollector->getName()); } - public function testCollectAndReset(): void + #[Test] + public function collectAndReset(): void { $this->commandHistoryLogger ->expects(self::exactly(2)) diff --git a/Tests/DependencyInjection/Compiler/RegisterCentrifugoPassTest.php b/Tests/DependencyInjection/Compiler/RegisterCentrifugoPassTest.php index d712186..5e36814 100755 --- a/Tests/DependencyInjection/Compiler/RegisterCentrifugoPassTest.php +++ b/Tests/DependencyInjection/Compiler/RegisterCentrifugoPassTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Service\Centrifugo; use Fresh\CentrifugoBundle\Service\CentrifugoInterface; use Fresh\CentrifugoBundle\Service\FakeCentrifugo; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SEEC\PhpUnit\Helper\ConsecutiveParams; @@ -50,7 +51,8 @@ protected function tearDown(): void ); } - public function testProcessFakeCentrifugo(): void + #[Test] + public function processFakeCentrifugo(): void { $this->containerBuilder ->expects(self::once()) @@ -70,7 +72,8 @@ public function testProcessFakeCentrifugo(): void $this->registerCentrifugoPass->process($this->containerBuilder); } - public function testProcessCentrifugo(): void + #[Test] + public function processCentrifugo(): void { $matcher = $this->exactly(3); diff --git a/Tests/DependencyInjection/FreshCentrifugoExtensionTest.php b/Tests/DependencyInjection/FreshCentrifugoExtensionTest.php index 65d5193..038ca5b 100755 --- a/Tests/DependencyInjection/FreshCentrifugoExtensionTest.php +++ b/Tests/DependencyInjection/FreshCentrifugoExtensionTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Service\CentrifugoInterface; use Fresh\CentrifugoBundle\Service\ResponseProcessor; use Fresh\DateTime\DateTimeHelper; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -45,7 +46,8 @@ protected function tearDown(): void ); } - public function testLoadExtension(): void + #[Test] + public function loadExtension(): void { $this->container->loadFromExtension($this->extension->getAlias()); $this->container->compile(); @@ -72,7 +74,8 @@ public function testLoadExtension(): void } } - public function testExceptionOnGettingPrivateService(): void + #[Test] + public function exceptionOnGettingPrivateService(): void { $this->container->loadFromExtension($this->extension->getAlias()); $this->container->compile(); diff --git a/Tests/Exception/CentrifugoErrorExceptionTest.php b/Tests/Exception/CentrifugoErrorExceptionTest.php index ff620d2..457e896 100755 --- a/Tests/Exception/CentrifugoErrorExceptionTest.php +++ b/Tests/Exception/CentrifugoErrorExceptionTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Exception\CentrifugoException; use Fresh\CentrifugoBundle\Exception\ExceptionInterface; use Fresh\CentrifugoBundle\Model\CommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -44,17 +45,20 @@ protected function tearDown(): void unset($this->exception); } - public function testGetCommand(): void + #[Test] + public function getCommand(): void { self::assertSame($this->command, $this->exception->getCommand()); } - public function testGetResponse(): void + #[Test] + public function getResponse(): void { self::assertSame($this->response, $this->exception->getResponse()); } - public function testException(): void + #[Test] + public function exception(): void { self::assertInstanceOf(CentrifugoException::class, $this->exception); self::assertInstanceOf(ExceptionInterface::class, $this->exception); diff --git a/Tests/Exception/CentrifugoExceptionTest.php b/Tests/Exception/CentrifugoExceptionTest.php index 33bb2c3..a551e3f 100755 --- a/Tests/Exception/CentrifugoExceptionTest.php +++ b/Tests/Exception/CentrifugoExceptionTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Exception\CentrifugoException; use Fresh\CentrifugoBundle\Exception\ExceptionInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -41,12 +42,14 @@ protected function tearDown(): void unset($this->exception); } - public function testGetResponse(): void + #[Test] + public function getResponse(): void { self::assertSame($this->response, $this->exception->getResponse()); } - public function testException(): void + #[Test] + public function exception(): void { self::assertInstanceOf(\Exception::class, $this->exception); self::assertInstanceOf(ExceptionInterface::class, $this->exception); diff --git a/Tests/Exception/InvalidArgumentExceptionTest.php b/Tests/Exception/InvalidArgumentExceptionTest.php index 412034d..8e773a6 100755 --- a/Tests/Exception/InvalidArgumentExceptionTest.php +++ b/Tests/Exception/InvalidArgumentExceptionTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Exception\ExceptionInterface; use Fresh\CentrifugoBundle\Exception\InvalidArgumentException; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -35,7 +36,8 @@ protected function tearDown(): void unset($this->exception); } - public function testException(): void + #[Test] + public function exception(): void { self::assertInstanceOf(ExceptionInterface::class, $this->exception); self::assertInstanceOf(\InvalidArgumentException::class, $this->exception); diff --git a/Tests/Exception/LogicExceptionTest.php b/Tests/Exception/LogicExceptionTest.php index f8808e8..ca7f797 100755 --- a/Tests/Exception/LogicExceptionTest.php +++ b/Tests/Exception/LogicExceptionTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Exception\ExceptionInterface; use Fresh\CentrifugoBundle\Exception\LogicException; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -35,7 +36,8 @@ protected function tearDown(): void unset($this->exception); } - public function testException(): void + #[Test] + public function exception(): void { self::assertInstanceOf(ExceptionInterface::class, $this->exception); self::assertInstanceOf(\LogicException::class, $this->exception); diff --git a/Tests/Exception/UnexpectedValueExceptionTest.php b/Tests/Exception/UnexpectedValueExceptionTest.php index ac6ee7b..728ebe9 100755 --- a/Tests/Exception/UnexpectedValueExceptionTest.php +++ b/Tests/Exception/UnexpectedValueExceptionTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Exception\ExceptionInterface; use Fresh\CentrifugoBundle\Exception\UnexpectedValueException; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -35,7 +36,8 @@ protected function tearDown(): void unset($this->exception); } - public function testException(): void + #[Test] + public function exception(): void { self::assertInstanceOf(ExceptionInterface::class, $this->exception); self::assertInstanceOf(\UnexpectedValueException::class, $this->exception); diff --git a/Tests/FreshCentrifugoBundleTest.php b/Tests/FreshCentrifugoBundleTest.php index 5447c67..23646fb 100755 --- a/Tests/FreshCentrifugoBundleTest.php +++ b/Tests/FreshCentrifugoBundleTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\DependencyInjection\Compiler\RegisterCentrifugoPass; use Fresh\CentrifugoBundle\FreshCentrifugoBundle; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -24,7 +25,8 @@ */ final class FreshCentrifugoBundleTest extends TestCase { - public function testBuild(): void + #[Test] + public function build(): void { $containerBuilder = $this->createMock(ContainerBuilder::class); $containerBuilder diff --git a/Tests/Logger/CommandHistoryLoggerTest.php b/Tests/Logger/CommandHistoryLoggerTest.php index d6fd9f0..d98bcc9 100755 --- a/Tests/Logger/CommandHistoryLoggerTest.php +++ b/Tests/Logger/CommandHistoryLoggerTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Logger\CommandHistoryLogger; use Fresh\CentrifugoBundle\Model\PublishCommand; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -35,7 +36,8 @@ protected function tearDown(): void unset($this->commandHistoryLogger); } - public function testConstructor(): void + #[Test] + public function constructor(): void { self::assertCount(0, $this->commandHistoryLogger->getCommandHistory()); self::assertSame(0, $this->commandHistoryLogger->getCommandsCount()); @@ -44,7 +46,8 @@ public function testConstructor(): void self::assertSame(0, $this->commandHistoryLogger->getFailedCommandsCount()); } - public function testRequestCount(): void + #[Test] + public function requestCount(): void { self::assertSame(0, $this->commandHistoryLogger->getRequestsCount()); $this->commandHistoryLogger->increaseRequestsCount(); @@ -57,7 +60,8 @@ public function testRequestCount(): void self::assertSame(0, $this->commandHistoryLogger->getRequestsCount()); } - public function testFullFlow(): void + #[Test] + public function fullFlow(): void { $command = new PublishCommand([], 'channelA'); $this->commandHistoryLogger->logCommand($command, true, ['test']); diff --git a/Tests/Model/BatchRequestTest.php b/Tests/Model/BatchRequestTest.php index 028a48a..cf0e4c2 100755 --- a/Tests/Model/BatchRequestTest.php +++ b/Tests/Model/BatchRequestTest.php @@ -17,6 +17,7 @@ use Fresh\CentrifugoBundle\Model\BroadcastCommand; use Fresh\CentrifugoBundle\Model\InfoCommand; use Fresh\CentrifugoBundle\Model\PublishCommand; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -40,7 +41,8 @@ protected function tearDown(): void unset($this->command); } - public function testGetCommands(): void + #[Test] + public function getCommands(): void { $commands = $this->command->getCommands(); self::assertInstanceOf(PublishCommand::class, $commands->current()); @@ -49,7 +51,8 @@ public function testGetCommands(): void self::assertInstanceOf(BroadcastCommand::class, $commands->current()); } - public function testAddCommandAndGetNumberOfCommands(): void + #[Test] + public function addCommandAndGetNumberOfCommands(): void { self::assertEquals(2, $this->command->getNumberOfCommands()); $this->command->addCommand(new InfoCommand()); @@ -61,7 +64,8 @@ public function testAddCommandAndGetNumberOfCommands(): void self::assertInstanceOf(InfoCommand::class, $commands->current()); } - public function testConstructorWithException(): void + #[Test] + public function constructorWithException(): void { $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('Invalid command for batch request. Only instances of Fresh\CentrifugoBundle\Model\CommandInterface are allowed.'); @@ -69,7 +73,8 @@ public function testConstructorWithException(): void new BatchRequest([new \stdClass()]); } - public function testGetChannels(): void + #[Test] + public function getChannels(): void { $channels = $this->command->getChannels(); self::assertEquals('channelA', $channels->current()); @@ -81,13 +86,15 @@ public function testGetChannels(): void self::assertEquals('channelC', $channels->current()); } - public function testPrepareLineDelimitedJsonWithEmptyBatchRequest(): void + #[Test] + public function prepareLineDelimitedJsonWithEmptyBatchRequest(): void { $batchRequest = new BatchRequest(); self::assertEquals('{}', $batchRequest->prepareLineDelimitedJson()); } - public function testPrepareLineDelimitedJsonWithNonEmptyBatchRequest(): void + #[Test] + public function prepareLineDelimitedJsonWithNonEmptyBatchRequest(): void { self::assertJsonStringEqualsJsonString( expectedJson: <<<'JSON' diff --git a/Tests/Model/BroadcastCommandTest.php b/Tests/Model/BroadcastCommandTest.php index f210c06..998d5a6 100755 --- a/Tests/Model/BroadcastCommandTest.php +++ b/Tests/Model/BroadcastCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\CommandInterface; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,7 +26,8 @@ */ final class BroadcastCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new BroadcastCommand( data: ['baz' => 'qux'], @@ -35,7 +37,8 @@ public function testInterfaces(): void self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new BroadcastCommand( data: ['baz' => 'qux'], @@ -46,7 +49,8 @@ public function testConstructor(): void self::assertEquals(['foo', 'bar'], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new BroadcastCommand( data: ['baz' => 'qux'], @@ -65,7 +69,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new BroadcastCommand( data: ['baz' => 'qux'], diff --git a/Tests/Model/ChannelsCommandTest.php b/Tests/Model/ChannelsCommandTest.php index 9edd11e..ee16241 100755 --- a/Tests/Model/ChannelsCommandTest.php +++ b/Tests/Model/ChannelsCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\CommandInterface; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +26,16 @@ */ final class ChannelsCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new ChannelsCommand(); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new ChannelsCommand(); self::assertEquals(Method::CHANNELS, $command->getMethod()); @@ -40,7 +43,8 @@ public function testConstructor(): void self::assertEquals([], $command->getChannels()); } - public function testSerializationWithoutPattern(): void + #[Test] + public function serializationWithoutPattern(): void { $command = new ChannelsCommand(); self::assertJsonStringEqualsJsonString( @@ -51,7 +55,8 @@ public function testSerializationWithoutPattern(): void ); } - public function testSerializationWithPattern(): void + #[Test] + public function serializationWithPattern(): void { $command = new ChannelsCommand(pattern: 'abc'); @@ -64,4 +69,11 @@ public function testSerializationWithPattern(): void \json_encode($command, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT) ); } + + #[Test] + public function processResponse(): void + { + $command = new ChannelsCommand(); + self::assertEquals(['foo' => 'bar'], $command->processResponse(['foo' => 'bar'])); + } } diff --git a/Tests/Model/DisconnectCommandTest.php b/Tests/Model/DisconnectCommandTest.php index f6e89e5..a506b33 100755 --- a/Tests/Model/DisconnectCommandTest.php +++ b/Tests/Model/DisconnectCommandTest.php @@ -17,6 +17,7 @@ use Fresh\CentrifugoBundle\Model\Disconnect; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -26,14 +27,16 @@ */ final class DisconnectCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new DisconnectCommand(user: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new DisconnectCommand(user: 'foo'); self::assertEquals(Method::DISCONNECT, $command->getMethod()); @@ -41,7 +44,8 @@ public function testConstructor(): void self::assertEquals([], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new DisconnectCommand(user: 'foo'); self::assertJsonStringEqualsJsonString( @@ -54,7 +58,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new DisconnectCommand( user: 'foo', diff --git a/Tests/Model/DisconnectTest.php b/Tests/Model/DisconnectTest.php index af4682a..bf50cdd 100755 --- a/Tests/Model/DisconnectTest.php +++ b/Tests/Model/DisconnectTest.php @@ -13,6 +13,7 @@ namespace Fresh\CentrifugoBundle\Tests\Model; use Fresh\CentrifugoBundle\Model\Disconnect; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -22,7 +23,8 @@ */ final class DisconnectTest extends TestCase { - public function testConstructor(): void + #[Test] + public function constructor(): void { $disconnectObject = new Disconnect(999, 'some reason'); self::assertSame(999, $disconnectObject->getCode()); diff --git a/Tests/Model/HistoryCommandTest.php b/Tests/Model/HistoryCommandTest.php index 4ae378b..0b5c60e 100755 --- a/Tests/Model/HistoryCommandTest.php +++ b/Tests/Model/HistoryCommandTest.php @@ -17,6 +17,7 @@ use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; use Fresh\CentrifugoBundle\Model\StreamPosition; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -26,14 +27,16 @@ */ final class HistoryCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new HistoryCommand(channel: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new HistoryCommand(channel: 'foo'); self::assertEquals(Method::HISTORY, $command->getMethod()); @@ -41,7 +44,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new HistoryCommand(channel: 'foo'); self::assertJsonStringEqualsJsonString( @@ -54,7 +58,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new HistoryCommand( channel: 'foo', @@ -78,7 +83,8 @@ public function testSerializationAllData(): void ); } - public function testSerializationWithZeroValues(): void + #[Test] + public function serializationWithZeroValues(): void { $command = new HistoryCommand( channel: 'foo', @@ -96,4 +102,16 @@ public function testSerializationWithZeroValues(): void \json_encode($command, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT) ); } + + #[Test] + public function processResponse(): void + { + $command = new HistoryCommand( + channel: 'foo', + reverse: true, + limit: 0, + streamPosition: new StreamPosition(offset: null, epoch: null), + ); + self::assertEquals(['foo' => 'bar'], $command->processResponse(['result' => ['foo' => 'bar']])); + } } diff --git a/Tests/Model/HistoryRemoveCommandTest.php b/Tests/Model/HistoryRemoveCommandTest.php index 0e12f2a..d4c0682 100755 --- a/Tests/Model/HistoryRemoveCommandTest.php +++ b/Tests/Model/HistoryRemoveCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\HistoryRemoveCommand; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +26,16 @@ */ final class HistoryRemoveCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new HistoryRemoveCommand(channel: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new HistoryRemoveCommand(channel: 'foo'); self::assertEquals(Method::HISTORY_REMOVE, $command->getMethod()); @@ -40,7 +43,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerialization(): void + #[Test] + public function serialization(): void { $command = new HistoryRemoveCommand(channel: 'foo'); self::assertJsonStringEqualsJsonString( diff --git a/Tests/Model/InfoCommandTest.php b/Tests/Model/InfoCommandTest.php index ce26819..efced7d 100755 --- a/Tests/Model/InfoCommandTest.php +++ b/Tests/Model/InfoCommandTest.php @@ -13,9 +13,12 @@ namespace Fresh\CentrifugoBundle\Tests\Model; use Fresh\CentrifugoBundle\Model\CommandInterface; +use Fresh\CentrifugoBundle\Model\HistoryCommand; use Fresh\CentrifugoBundle\Model\InfoCommand; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use Fresh\CentrifugoBundle\Model\StreamPosition; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +28,16 @@ */ final class InfoCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new InfoCommand(); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new InfoCommand(); self::assertEquals(Method::INFO, $command->getMethod()); @@ -40,7 +45,8 @@ public function testConstructor(): void self::assertEquals([], $command->getChannels()); } - public function testSerialization(): void + #[Test] + public function serialization(): void { $command = new InfoCommand(); self::assertJsonStringEqualsJsonString( @@ -50,4 +56,11 @@ public function testSerialization(): void \json_encode($command, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT) ); } + + #[Test] + public function processResponse(): void + { + $command = new InfoCommand(); + self::assertEquals(['foo' => 'bar'], $command->processResponse(['result' => ['foo' => 'bar']])); + } } diff --git a/Tests/Model/PresenceCommandTest.php b/Tests/Model/PresenceCommandTest.php index 25bf6a7..01a88fe 100755 --- a/Tests/Model/PresenceCommandTest.php +++ b/Tests/Model/PresenceCommandTest.php @@ -13,9 +13,11 @@ namespace Fresh\CentrifugoBundle\Tests\Model; use Fresh\CentrifugoBundle\Model\CommandInterface; +use Fresh\CentrifugoBundle\Model\InfoCommand; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\PresenceCommand; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +27,16 @@ */ final class PresenceCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new PresenceCommand(channel: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new PresenceCommand(channel: 'foo'); self::assertEquals(Method::PRESENCE, $command->getMethod()); @@ -40,7 +44,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerialization(): void + #[Test] + public function serialization(): void { $command = new PresenceCommand(channel: 'foo'); self::assertJsonStringEqualsJsonString( @@ -52,4 +57,11 @@ public function testSerialization(): void \json_encode($command, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT) ); } + + #[Test] + public function processResponse(): void + { + $command = new PresenceCommand(channel: 'foo'); + self::assertEquals(['foo' => 'bar'], $command->processResponse(['result' => ['presence' => ['foo' => 'bar']]])); + } } diff --git a/Tests/Model/PresenceStatsCommandTest.php b/Tests/Model/PresenceStatsCommandTest.php index 6ee1432..cfd5ba2 100755 --- a/Tests/Model/PresenceStatsCommandTest.php +++ b/Tests/Model/PresenceStatsCommandTest.php @@ -14,8 +14,10 @@ use Fresh\CentrifugoBundle\Model\CommandInterface; use Fresh\CentrifugoBundle\Model\Method; +use Fresh\CentrifugoBundle\Model\PresenceCommand; use Fresh\CentrifugoBundle\Model\PresenceStatsCommand; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +27,16 @@ */ final class PresenceStatsCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new PresenceStatsCommand(channel: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new PresenceStatsCommand(channel: 'foo'); self::assertEquals(Method::PRESENCE_STATS, $command->getMethod()); @@ -40,7 +44,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerialization(): void + #[Test] + public function serialization(): void { $command = new PresenceStatsCommand(channel: 'foo'); self::assertJsonStringEqualsJsonString( @@ -52,4 +57,11 @@ public function testSerialization(): void \json_encode($command, \JSON_THROW_ON_ERROR | \JSON_FORCE_OBJECT) ); } + + #[Test] + public function processResponse(): void + { + $command = new PresenceStatsCommand(channel: 'foo'); + self::assertEquals(['foo' => 'bar'], $command->processResponse(['result' => ['foo' => 'bar']])); + } } diff --git a/Tests/Model/PublishCommandTest.php b/Tests/Model/PublishCommandTest.php index dfc7c7f..57df2a0 100755 --- a/Tests/Model/PublishCommandTest.php +++ b/Tests/Model/PublishCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\PublishCommand; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,7 +26,8 @@ */ final class PublishCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new PublishCommand( data: ['bar' => 'baz'], @@ -35,7 +37,8 @@ public function testInterfaces(): void self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new PublishCommand( data: ['bar' => 'baz'], @@ -46,7 +49,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new PublishCommand( data: ['bar' => 'baz'], @@ -65,7 +69,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new PublishCommand( data: ['bar' => 'baz'], diff --git a/Tests/Model/RefreshCommandTest.php b/Tests/Model/RefreshCommandTest.php index 2f728d2..1d5c8f1 100755 --- a/Tests/Model/RefreshCommandTest.php +++ b/Tests/Model/RefreshCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\RefreshCommand; use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,14 +26,16 @@ */ final class RefreshCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new RefreshCommand(user: 'foo'); self::assertInstanceOf(SerializableCommandInterface::class, $command); self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new RefreshCommand(user: 'foo'); self::assertEquals(Method::REFRESH, $command->getMethod()); @@ -40,7 +43,8 @@ public function testConstructor(): void self::assertEquals([], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new RefreshCommand(user: 'foo'); self::assertJsonStringEqualsJsonString( @@ -53,7 +57,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new RefreshCommand( user: 'foo', diff --git a/Tests/Model/StreamPositionTest.php b/Tests/Model/StreamPositionTest.php index 9d83bda..2e4bfba 100755 --- a/Tests/Model/StreamPositionTest.php +++ b/Tests/Model/StreamPositionTest.php @@ -13,6 +13,7 @@ namespace Fresh\CentrifugoBundle\Tests\Model; use Fresh\CentrifugoBundle\Model\StreamPosition; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -22,7 +23,8 @@ */ final class StreamPositionTest extends TestCase { - public function testConstructor(): void + #[Test] + public function constructor(): void { $streamPosition = new StreamPosition(5, 'ABCD'); self::assertSame(5, $streamPosition->getOffset()); diff --git a/Tests/Model/SubscribeCommandTest.php b/Tests/Model/SubscribeCommandTest.php index 114b82b..1970d14 100755 --- a/Tests/Model/SubscribeCommandTest.php +++ b/Tests/Model/SubscribeCommandTest.php @@ -18,6 +18,7 @@ use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; use Fresh\CentrifugoBundle\Model\StreamPosition; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -27,7 +28,8 @@ */ final class SubscribeCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new SubscribeCommand( user: 'user123', @@ -37,7 +39,8 @@ public function testInterfaces(): void self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new SubscribeCommand( user: 'user123', @@ -48,7 +51,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new SubscribeCommand( user: 'user123', @@ -65,7 +69,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new SubscribeCommand( user: 'user123', @@ -117,7 +122,8 @@ public function testSerializationAllData(): void ); } - public function testSerializationWithZeroValues(): void + #[Test] + public function serializationWithZeroValues(): void { $command = new SubscribeCommand( user: 'user123', diff --git a/Tests/Model/UnsubscribeCommandTest.php b/Tests/Model/UnsubscribeCommandTest.php index 46a553f..96e2481 100755 --- a/Tests/Model/UnsubscribeCommandTest.php +++ b/Tests/Model/UnsubscribeCommandTest.php @@ -16,6 +16,7 @@ use Fresh\CentrifugoBundle\Model\Method; use Fresh\CentrifugoBundle\Model\SerializableCommandInterface; use Fresh\CentrifugoBundle\Model\UnsubscribeCommand; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -25,7 +26,8 @@ */ final class UnsubscribeCommandTest extends TestCase { - public function testInterfaces(): void + #[Test] + public function interfaces(): void { $command = new UnsubscribeCommand( user: 'bar', @@ -35,7 +37,8 @@ public function testInterfaces(): void self::assertInstanceOf(CommandInterface::class, $command); } - public function testConstructor(): void + #[Test] + public function constructor(): void { $command = new UnsubscribeCommand( user: 'bar', @@ -46,7 +49,8 @@ public function testConstructor(): void self::assertEquals(['foo'], $command->getChannels()); } - public function testSerializationRequiredData(): void + #[Test] + public function serializationRequiredData(): void { $command = new UnsubscribeCommand( user: 'bar', @@ -63,7 +67,8 @@ public function testSerializationRequiredData(): void ); } - public function testSerializationAllData(): void + #[Test] + public function serializationAllData(): void { $command = new UnsubscribeCommand( user: 'bar', diff --git a/Tests/Service/CentrifugoCheckerTest.php b/Tests/Service/CentrifugoCheckerTest.php index cee7be2..d659715 100755 --- a/Tests/Service/CentrifugoCheckerTest.php +++ b/Tests/Service/CentrifugoCheckerTest.php @@ -15,6 +15,7 @@ use Fresh\CentrifugoBundle\Exception\CentrifugoException; use Fresh\CentrifugoBundle\Exception\InvalidArgumentException; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -45,7 +46,8 @@ protected function tearDown(): void ); } - public function testInvalidChannelName(): void + #[Test] + public function invalidChannelName(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid channel name. Only ASCII symbols must be used in channel string.'); @@ -53,7 +55,8 @@ public function testInvalidChannelName(): void $this->centrifugoChecker->assertValidChannelName('Hallöchen'); } - public function testInvalidChannelNameLength(): void + #[Test] + public function invalidChannelNameLength(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid channel name length. Maximum allowed length is 10.'); @@ -61,12 +64,14 @@ public function testInvalidChannelNameLength(): void $this->centrifugoChecker->assertValidChannelName('ABCDEFGHIJK'); } - public function testValidChannelName(): void + #[Test] + public function validChannelName(): void { self::assertTrue($this->centrifugoChecker->assertValidChannelName('1234567890')); } - public function testInvalidResponseStatusCode(): void + #[Test] + public function invalidResponseStatusCode(): void { $this->response ->expects(self::once()) @@ -80,7 +85,8 @@ public function testInvalidResponseStatusCode(): void $this->centrifugoChecker->assertValidResponseStatusCode($this->response); } - public function testValidResponseStatusCode(): void + #[Test] + public function validResponseStatusCode(): void { $this->response ->expects(self::once()) @@ -91,7 +97,8 @@ public function testValidResponseStatusCode(): void $this->centrifugoChecker->assertValidResponseStatusCode($this->response); } - public function testInvalidResponseHeaders(): void + #[Test] + public function invalidResponseHeaders(): void { $this->response ->expects(self::once()) @@ -106,7 +113,8 @@ public function testInvalidResponseHeaders(): void $this->centrifugoChecker->assertValidResponseHeaders($this->response); } - public function testValidResponseHeaders(): void + #[Test] + public function validResponseHeaders(): void { $this->response ->expects(self::once()) @@ -118,7 +126,8 @@ public function testValidResponseHeaders(): void $this->centrifugoChecker->assertValidResponseHeaders($this->response); } - public function testInvalidResponseContentType(): void + #[Test] + public function invalidResponseContentType(): void { $this->response ->expects(self::once()) @@ -133,7 +142,8 @@ public function testInvalidResponseContentType(): void $this->centrifugoChecker->assertValidResponseContentType($this->response); } - public function testValidResponseContentType(): void + #[Test] + public function validResponseContentType(): void { $this->response ->expects(self::once()) diff --git a/Tests/Service/CentrifugoTest.php b/Tests/Service/CentrifugoTest.php index 38f9018..51cd634 100755 --- a/Tests/Service/CentrifugoTest.php +++ b/Tests/Service/CentrifugoTest.php @@ -19,6 +19,7 @@ use Fresh\CentrifugoBundle\Service\Centrifugo; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\ResponseProcessor; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SEEC\PhpUnit\Helper\ConsecutiveParams; @@ -87,7 +88,8 @@ protected function tearDown(): void ); } - public function testPublishCommand(): void + #[Test] + public function publishCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -122,7 +124,8 @@ public function testPublishCommand(): void ); } - public function testBroadcastCommand(): void + #[Test] + public function broadcastCommand(): void { $this->centrifugoChecker ->expects(self::exactly(2)) @@ -160,7 +163,8 @@ public function testBroadcastCommand(): void ); } - public function testUnsubscribeCommand(): void + #[Test] + public function unsubscribeCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -194,7 +198,8 @@ public function testUnsubscribeCommand(): void ); } - public function testSubscribeCommand(): void + #[Test] + public function subscribeCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -240,7 +245,8 @@ public function testSubscribeCommand(): void ); } - public function testDisconnectCommand(): void + #[Test] + public function disconnectCommand(): void { $this->centrifugoChecker ->expects(self::never()) @@ -274,7 +280,8 @@ public function testDisconnectCommand(): void ); } - public function testRefreshCommand(): void + #[Test] + public function refreshCommand(): void { $this->centrifugoChecker ->expects(self::never()) @@ -308,7 +315,8 @@ public function testRefreshCommand(): void ); } - public function testPresenceCommand(): void + #[Test] + public function presenceCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -337,7 +345,8 @@ public function testPresenceCommand(): void $this->centrifugo->presence(channel: 'channelA'); } - public function testPresenceStatsCommand(): void + #[Test] + public function presenceStatsCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -366,7 +375,8 @@ public function testPresenceStatsCommand(): void $this->centrifugo->presenceStats(channel: 'channelA'); } - public function testHistoryCommand(): void + #[Test] + public function historyCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -400,7 +410,8 @@ public function testHistoryCommand(): void ); } - public function testHistoryRemoveCommand(): void + #[Test] + public function historyRemoveCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -429,7 +440,8 @@ public function testHistoryRemoveCommand(): void $this->centrifugo->historyRemove(channel: 'channelA'); } - public function testChannelsCommand(): void + #[Test] + public function channelsCommand(): void { $this->centrifugoChecker ->expects(self::never()) @@ -457,7 +469,8 @@ public function testChannelsCommand(): void $this->centrifugo->channels(pattern: 'pattern'); } - public function testInfoCommand(): void + #[Test] + public function infoCommand(): void { $this->centrifugoChecker ->expects(self::never()) @@ -485,7 +498,8 @@ public function testInfoCommand(): void $this->centrifugo->info(); } - public function testBatchRequest(): void + #[Test] + public function batchRequest(): void { $this->centrifugoChecker ->expects(self::exactly(2)) diff --git a/Tests/Service/ChannelAuthenticator/PrivateChannelAuthenticatorTest.php b/Tests/Service/ChannelAuthenticator/PrivateChannelAuthenticatorTest.php index 29e3a0b..e3a88ed 100755 --- a/Tests/Service/ChannelAuthenticator/PrivateChannelAuthenticatorTest.php +++ b/Tests/Service/ChannelAuthenticator/PrivateChannelAuthenticatorTest.php @@ -15,6 +15,8 @@ use Fresh\CentrifugoBundle\Service\ChannelAuthenticator\ChannelAuthenticatorInterface; use Fresh\CentrifugoBundle\Service\ChannelAuthenticator\PrivateChannelAuthenticator; use Fresh\CentrifugoBundle\Service\Credentials\CredentialsGenerator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SEEC\PhpUnit\Helper\ConsecutiveParams; @@ -62,7 +64,8 @@ protected function tearDown(): void ); } - public function testInvalidJsonRequest(): void + #[Test] + public function invalidJsonRequest(): void { $this->request ->expects(self::once()) @@ -81,11 +84,8 @@ public function testInvalidJsonRequest(): void self::assertEquals(['channels' => []], $this->privateChannelAuthenticator->authChannelsForClientFromRequest($this->request)); } - /** - * @param string $content - * - * @dataProvider dataProviderForTestInvalidClientInRequest - */ + #[Test] + #[DataProvider('dataProviderForTestInvalidClientInRequest')] public function testInvalidClientInRequest(string $content): void { $this->request @@ -143,11 +143,7 @@ public static function dataProviderForTestInvalidClientInRequest(): iterable ]; } - /** - * @param string $content - * - * @dataProvider dataProviderForTestInvalidChannelsInRequest - */ + #[DataProvider('dataProviderForTestInvalidChannelsInRequest')] public function testInvalidChannelsInRequest(string $content): void { $this->request @@ -196,7 +192,8 @@ public static function dataProviderForTestInvalidChannelsInRequest(): iterable ]; } - public function testNonStringChannelInRequest(): void + #[Test] + public function nonStringChannelInRequest(): void { $this->request ->expects(self::once()) @@ -220,7 +217,8 @@ public function testNonStringChannelInRequest(): void self::assertEquals(['channels' => []], $this->privateChannelAuthenticator->authChannelsForClientFromRequest($this->request)); } - public function testExceptionOnGetContent(): void + #[Test] + public function exceptionOnGetContent(): void { $this->request ->expects(self::once()) @@ -239,7 +237,8 @@ public function testExceptionOnGetContent(): void self::assertEquals(['channels' => []], $this->privateChannelAuthenticator->authChannelsForClientFromRequest($this->request)); } - public function testNoChannelAuthenticator(): void + #[Test] + public function noChannelAuthenticator(): void { $this->request ->expects(self::once()) @@ -262,7 +261,8 @@ public function testNoChannelAuthenticator(): void self::assertEquals(['channels' => []], $this->privateChannelAuthenticator->authChannelsForClientFromRequest($this->request)); } - public function testSuccessChannelAuthenticator(): void + #[Test] + public function successChannelAuthenticator(): void { $this->request ->expects(self::once()) diff --git a/Tests/Service/Credentials/CredentialsGeneratorTest.php b/Tests/Service/Credentials/CredentialsGeneratorTest.php index 2dbb7f7..12411be 100755 --- a/Tests/Service/Credentials/CredentialsGeneratorTest.php +++ b/Tests/Service/Credentials/CredentialsGeneratorTest.php @@ -19,6 +19,7 @@ use Fresh\CentrifugoBundle\Token\JwtPayloadForPrivateChannel; use Fresh\CentrifugoBundle\User\CentrifugoUserInterface; use Fresh\DateTime\DateTimeHelper; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -53,7 +54,8 @@ protected function tearDown(): void ); } - public function testGenerateJwtTokenForAnonymous(): void + #[Test] + public function generateJwtTokenForAnonymous(): void { $this->dateTimeHelper ->expects(self::once()) @@ -78,7 +80,8 @@ public function testGenerateJwtTokenForAnonymous(): void self::assertEquals('test1', $this->credentialsGenerator->generateJwtTokenForAnonymous()); } - public function testGenerateJwtTokenForUser(): void + #[Test] + public function generateJwtTokenForUser(): void { $this->dateTimeHelper ->expects(self::once()) @@ -120,7 +123,8 @@ public function testGenerateJwtTokenForUser(): void self::assertEquals('test2', $this->credentialsGenerator->generateJwtTokenForUser($user, 'qwerty', ['channelA'])); } - public function testGenerateJwtTokenForPrivateChannel(): void + #[Test] + public function generateJwtTokenForPrivateChannel(): void { $this->dateTimeHelper ->expects(self::once()) @@ -146,7 +150,8 @@ public function testGenerateJwtTokenForPrivateChannel(): void self::assertEquals('test3', $this->credentialsGenerator->generateJwtTokenForPrivateChannel('spiderman', 'avengers', null, true)); } - public function testGenerateJwtTokenForChannel(): void + #[Test] + public function generateJwtTokenForChannel(): void { $this->dateTimeHelper ->expects(self::once()) diff --git a/Tests/Service/FakeCentrifugoTest.php b/Tests/Service/FakeCentrifugoTest.php index 848e4f6..1e8dafc 100755 --- a/Tests/Service/FakeCentrifugoTest.php +++ b/Tests/Service/FakeCentrifugoTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Model; use Fresh\CentrifugoBundle\Service\FakeCentrifugo; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -37,7 +38,8 @@ protected function tearDown(): void ); } - public function testAllMethods(): void + #[Test] + public function allMethods(): void { $this->centrifugo->publish(['foo' => 'bar'], 'channelA'); $this->centrifugo->broadcast(['foo' => 'bar'], ['channelA', 'channelB']); diff --git a/Tests/Service/Jwt/JwtGeneratorTest.php b/Tests/Service/Jwt/JwtGeneratorTest.php index 909049b..0fbf6fe 100755 --- a/Tests/Service/Jwt/JwtGeneratorTest.php +++ b/Tests/Service/Jwt/JwtGeneratorTest.php @@ -17,6 +17,7 @@ use Fresh\CentrifugoBundle\Token\JwtPayloadForChannel; use Fresh\CentrifugoBundle\Token\JwtPayloadForChannelOverride; use Fresh\CentrifugoBundle\Token\JwtPayloadForPrivateChannel; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -38,7 +39,8 @@ protected function tearDown(): void unset($this->jwtGenerator); } - public function testGenerateTokenForAllClaims(): void + #[Test] + public function generateTokenForAllClaims(): void { $jwtPayload = new JwtPayload( 'spiderman', @@ -57,7 +59,8 @@ public function testGenerateTokenForAllClaims(): void ); } - public function testGenerateTokenForOnlyRequiredClaims(): void + #[Test] + public function generateTokenForOnlyRequiredClaims(): void { $jwtPayload = new JwtPayload('spiderman'); @@ -67,7 +70,8 @@ public function testGenerateTokenForOnlyRequiredClaims(): void ); } - public function testGenerateTokenForPrivateChannelForAllClaims(): void + #[Test] + public function generateTokenForPrivateChannelForAllClaims(): void { $jwtPayloadForPrivateChannel = new JwtPayloadForPrivateChannel( 'spiderman', @@ -87,7 +91,8 @@ public function testGenerateTokenForPrivateChannelForAllClaims(): void ); } - public function testGenerateTokenForPrivateChannelForOnlyRequiredClaims(): void + #[Test] + public function generateTokenForPrivateChannelForOnlyRequiredClaims(): void { $jwtPayloadForPrivateChannel = new JwtPayloadForPrivateChannel('spiderman', 'avengers'); @@ -97,7 +102,8 @@ public function testGenerateTokenForPrivateChannelForOnlyRequiredClaims(): void ); } - public function testGenerateTokenForChannelForAllClaims(): void + #[Test] + public function generateTokenForChannelForAllClaims(): void { $jwtPayloadForChannel = new JwtPayloadForChannel( 'spiderman', @@ -122,7 +128,8 @@ public function testGenerateTokenForChannelForAllClaims(): void ); } - public function testGenerateTokenForChannelForOnlyRequiredClaims(): void + #[Test] + public function generateTokenForChannelForOnlyRequiredClaims(): void { $jwtPayloadForChannel = new JwtPayloadForChannel('spiderman', 'avengers'); diff --git a/Tests/Service/ResponseProcessorTest.php b/Tests/Service/ResponseProcessorTest.php index a80a301..55fb918 100755 --- a/Tests/Service/ResponseProcessorTest.php +++ b/Tests/Service/ResponseProcessorTest.php @@ -24,6 +24,7 @@ use Fresh\CentrifugoBundle\Model\ResultableCommandInterface; use Fresh\CentrifugoBundle\Service\CentrifugoChecker; use Fresh\CentrifugoBundle\Service\ResponseProcessor; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SEEC\PhpUnit\Helper\ConsecutiveParams; @@ -77,7 +78,8 @@ protected function tearDown(): void ); } - public function testProcessingBatchRequest(): void + #[Test] + public function processingBatchRequest(): void { $this->centrifugoChecker ->expects(self::once()) @@ -103,7 +105,7 @@ public function testProcessingBatchRequest(): void "replies": [ {"publish": {}}, {"broadcast": {}}, - {"channels": ["chat", "notification"]} + ["chat", "notification"] ] } JSON @@ -142,7 +144,8 @@ public function testProcessingBatchRequest(): void ); } - public function testLogicException(): void + #[Test] + public function logicException(): void { $this->response ->expects(self::once()) @@ -150,7 +153,7 @@ public function testLogicException(): void ->willReturn(<<<'JSON' { "replies": { - "result":{"channels":["chat","notification"]} + "result":["chat","notification"] } } JSON @@ -172,7 +175,8 @@ public function testLogicException(): void ); } - public function testProcessingResultableCommand(): void + #[Test] + public function processingResultableCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -194,9 +198,7 @@ public function testProcessingResultableCommand(): void ->expects(self::once()) ->method('getContent') ->willReturn(<<<'JSON' - { - "channels": ["foo", "bar"] - } + ["foo", "bar"] JSON ) ; @@ -213,7 +215,8 @@ public function testProcessingResultableCommand(): void self::assertSame(['foo', 'bar'], $result); } - public function testProcessingNonResultableCommand(): void + #[Test] + public function processingNonResultableCommand(): void { $this->centrifugoChecker ->expects(self::once()) @@ -258,7 +261,8 @@ public function testProcessingNonResultableCommand(): void self::assertNull($result); } - public function testInvalidResponse(): void + #[Test] + public function invalidResponse(): void { $this->response ->expects(self::once()) @@ -275,7 +279,8 @@ public function testInvalidResponse(): void ); } - public function testProcessingCentrifugoErrorForSingleCommand(): void + #[Test] + public function processingCentrifugoErrorForSingleCommand(): void { $this->response ->expects(self::once()) @@ -298,7 +303,8 @@ public function testProcessingCentrifugoErrorForSingleCommand(): void $this->responseProcessor->processResponse($command, $this->response); } - public function testProcessingCentrifugoErrorForBatchRequest(): void + #[Test] + public function processingCentrifugoErrorForBatchRequest(): void { $this->response ->expects(self::once()) @@ -308,7 +314,7 @@ public function testProcessingCentrifugoErrorForBatchRequest(): void "replies": [ {"error":{"message":"test message 2","code":456}}, {"broadcast":{}}, - {"channels":["chat","notification"]} + ["chat","notification"] ] } JSON diff --git a/Tests/Token/JwtPayloadForChannelTest.php b/Tests/Token/JwtPayloadForChannelTest.php index aa9cc2a..4b4311b 100755 --- a/Tests/Token/JwtPayloadForChannelTest.php +++ b/Tests/Token/JwtPayloadForChannelTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Token\JwtPayloadForChannel; use Fresh\CentrifugoBundle\Token\JwtPayloadForChannelOverride; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -21,7 +22,8 @@ */ final class JwtPayloadForChannelTest extends TestCase { - public function testConstructor(): void + #[Test] + public function constructor(): void { $jwtPayloadForChannel = new JwtPayloadForChannel( 'spiderman', @@ -65,7 +67,8 @@ public function testConstructor(): void self::assertTrue($jwtPayloadForChannel->getOverride()->getForcePosting()); } - public function testGetPayloadDataWithAllClaims(): void + #[Test] + public function getPayloadDataWithAllClaims(): void { $jwtPayloadForChannel = new JwtPayloadForChannel( 'spiderman', @@ -121,7 +124,8 @@ public function testGetPayloadDataWithAllClaims(): void ); } - public function testGetPayloadDataWithOnlyRequiredClaims(): void + #[Test] + public function getPayloadDataWithOnlyRequiredClaims(): void { $jwtPayloadForChannel = new JwtPayloadForChannel( 'spiderman', diff --git a/Tests/Token/JwtPayloadForPrivateChannelTest.php b/Tests/Token/JwtPayloadForPrivateChannelTest.php index 85e02bb..f6cd7d1 100755 --- a/Tests/Token/JwtPayloadForPrivateChannelTest.php +++ b/Tests/Token/JwtPayloadForPrivateChannelTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Token\AbstractJwtPayload; use Fresh\CentrifugoBundle\Token\JwtPayloadForPrivateChannel; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -23,7 +24,8 @@ */ final class JwtPayloadForPrivateChannelTest extends TestCase { - public function testConstructor(): void + #[Test] + public function constructor(): void { $jwtPayloadForPrivateChannel = new JwtPayloadForPrivateChannel( 'spiderman', @@ -52,7 +54,8 @@ public function testConstructor(): void self::assertTrue($jwtPayloadForPrivateChannel->isEto()); } - public function testGetPayloadDataWithAllClaims(): void + #[Test] + public function getPayloadDataWithAllClaims(): void { $jwtPayloadForPrivateChannel = new JwtPayloadForPrivateChannel( 'spiderman', @@ -82,7 +85,8 @@ public function testGetPayloadDataWithAllClaims(): void ); } - public function testGetPayloadDataWithOnlyRequiredClaims(): void + #[Test] + public function getPayloadDataWithOnlyRequiredClaims(): void { $jwtPayloadForPrivateChannel = new JwtPayloadForPrivateChannel( 'spiderman', diff --git a/Tests/Token/JwtPayloadTest.php b/Tests/Token/JwtPayloadTest.php index 9e0ff60..bfbe5e7 100755 --- a/Tests/Token/JwtPayloadTest.php +++ b/Tests/Token/JwtPayloadTest.php @@ -14,6 +14,7 @@ use Fresh\CentrifugoBundle\Token\AbstractJwtPayload; use Fresh\CentrifugoBundle\Token\JwtPayload; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -23,7 +24,8 @@ */ final class JwtPayloadTest extends TestCase { - public function testConstructor(): void + #[Test] + public function constructor(): void { $jwtPayload = new JwtPayload( 'spiderman', @@ -50,7 +52,8 @@ public function testConstructor(): void self::assertSame(['avengers'], $jwtPayload->getChannels()); } - public function testGetPayloadDataWithAllClaims(): void + #[Test] + public function getPayloadDataWithAllClaims(): void { $jwtPayload = new JwtPayload( 'spiderman', @@ -78,7 +81,8 @@ public function testGetPayloadDataWithAllClaims(): void ); } - public function testGetPayloadDataWithOnlyRequiredClaims(): void + #[Test] + public function getPayloadDataWithOnlyRequiredClaims(): void { $jwtPayload = new JwtPayload( 'spiderman' diff --git a/composer.json b/composer.json index 9fa3121..e1126ee 100755 --- a/composer.json +++ b/composer.json @@ -37,10 +37,10 @@ "require-dev": { "escapestudios/symfony2-coding-standard": "^3.13", "jetbrains/phpstorm-attributes": "^1.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.11", "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/phpstan-symfony": "^1.3", + "phpstan/phpstan-phpunit": "^1.4", + "phpstan/phpstan-symfony": "^1.4", "phpunit/phpunit": "^10.5", "seec/phpunit-consecutive-params": "^1.1", "slam/phpstan-extensions": "^6.1" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ad732df..33f8d14 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@