From 3d958f3f92659f5da4c746dcb204941ab4d22f16 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 26 Apr 2026 20:28:07 +0300 Subject: [PATCH] Update tests --- src/Models/Attachments/Buttons/Inline/ClipboardButton.php | 5 ++--- tests/ApiFactoryMethodsTest.php | 2 ++ tests/ApiTest.php | 2 ++ tests/ClientTest.php | 2 ++ tests/Laravel/Commands/PollingStartCommandTest.php | 2 ++ tests/Laravel/Commands/WebhookListCommandTest.php | 2 ++ tests/Laravel/Commands/WebhookSubscribeCommandTest.php | 2 ++ tests/Laravel/Commands/WebhookUnsubscribeCommandTest.php | 2 ++ tests/Laravel/MaxBotManagerTest.php | 2 ++ tests/Laravel/MaxBotServiceProviderTest.php | 2 ++ tests/LongPollingHandlerTest.php | 2 ++ .../Attachments/Buttons/Inline/ClipboardButtonTest.php | 4 +--- tests/UpdateDispatcherTest.php | 2 ++ tests/WebhookHandlerTest.php | 2 ++ 14 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Models/Attachments/Buttons/Inline/ClipboardButton.php b/src/Models/Attachments/Buttons/Inline/ClipboardButton.php index 2f39ebf..6cf33ca 100644 --- a/src/Models/Attachments/Buttons/Inline/ClipboardButton.php +++ b/src/Models/Attachments/Buttons/Inline/ClipboardButton.php @@ -7,11 +7,10 @@ namespace BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline; use BushlanovDev\MaxMessengerBot\Enums\InlineButtonType; /** - * Opens the bot's mini-application. + * A button that, when clicked, copies text to the clipboard. */ final readonly class ClipboardButton extends AbstractInlineButton { - public ?string $payload; /** @@ -21,7 +20,7 @@ final readonly class ClipboardButton extends AbstractInlineButton public function __construct(string $text, string $payload) { parent::__construct(InlineButtonType::Clipboard, $text); - + $this->payload = $payload; } } diff --git a/tests/ApiFactoryMethodsTest.php b/tests/ApiFactoryMethodsTest.php index b734687..75e6af4 100644 --- a/tests/ApiFactoryMethodsTest.php +++ b/tests/ApiFactoryMethodsTest.php @@ -10,6 +10,7 @@ use BushlanovDev\MaxMessengerBot\LongPollingHandler; use BushlanovDev\MaxMessengerBot\ModelFactory; use BushlanovDev\MaxMessengerBot\UpdateDispatcher; use BushlanovDev\MaxMessengerBot\WebhookHandler; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -19,6 +20,7 @@ use Psr\Log\LoggerInterface; use ReflectionClass; #[CoversClass(Api::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(UpdateDispatcher::class)] #[UsesClass(WebhookHandler::class)] #[UsesClass(LongPollingHandler::class)] diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 1ae4a1e..04fc274 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -62,6 +62,7 @@ use InvalidArgumentException; use LogicException; use org\bovigo\vfs\vfsStream; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -75,6 +76,7 @@ use ReflectionClass; use RuntimeException; #[CoversClass(Api::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Result::class)] #[UsesClass(Client::class)] #[UsesClass(BotInfo::class)] diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 7e821e8..fde44bb 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -16,6 +16,7 @@ use BushlanovDev\MaxMessengerBot\Exceptions\SerializationException; use BushlanovDev\MaxMessengerBot\Exceptions\UnauthorizedException; use GuzzleHttp\Psr7\HttpFactory; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; @@ -32,6 +33,7 @@ use Psr\Http\Message\StreamInterface; use Psr\Log\LoggerInterface; #[CoversClass(Client::class)] +#[AllowMockObjectsWithoutExpectations] final class ClientTest extends TestCase { private const string FAKE_TOKEN = '12345:abcdef'; diff --git a/tests/Laravel/Commands/PollingStartCommandTest.php b/tests/Laravel/Commands/PollingStartCommandTest.php index e768513..02f5fab 100644 --- a/tests/Laravel/Commands/PollingStartCommandTest.php +++ b/tests/Laravel/Commands/PollingStartCommandTest.php @@ -7,6 +7,7 @@ namespace BushlanovDev\MaxMessengerBot\Tests\Laravel\Commands; use BushlanovDev\MaxMessengerBot\Laravel\Commands\PollingStartCommand; use BushlanovDev\MaxMessengerBot\Laravel\MaxBotManager; use Illuminate\Support\Facades\Log; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -15,6 +16,7 @@ use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; #[CoversClass(PollingStartCommand::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(MaxBotManager::class)] final class PollingStartCommandTest extends TestCase { diff --git a/tests/Laravel/Commands/WebhookListCommandTest.php b/tests/Laravel/Commands/WebhookListCommandTest.php index 558741e..8e54143 100644 --- a/tests/Laravel/Commands/WebhookListCommandTest.php +++ b/tests/Laravel/Commands/WebhookListCommandTest.php @@ -9,6 +9,7 @@ use BushlanovDev\MaxMessengerBot\Enums\UpdateType; use BushlanovDev\MaxMessengerBot\Laravel\Commands\WebhookListCommand; use BushlanovDev\MaxMessengerBot\Models\Subscription; use Illuminate\Support\Facades\Log; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -17,6 +18,7 @@ use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; #[CoversClass(WebhookListCommand::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Api::class)] #[UsesClass(Subscription::class)] final class WebhookListCommandTest extends TestCase diff --git a/tests/Laravel/Commands/WebhookSubscribeCommandTest.php b/tests/Laravel/Commands/WebhookSubscribeCommandTest.php index 910de25..33cc26b 100644 --- a/tests/Laravel/Commands/WebhookSubscribeCommandTest.php +++ b/tests/Laravel/Commands/WebhookSubscribeCommandTest.php @@ -10,6 +10,7 @@ use BushlanovDev\MaxMessengerBot\Laravel\Commands\WebhookSubscribeCommand; use BushlanovDev\MaxMessengerBot\Models\Result; use Illuminate\Contracts\Config\Repository as Config; use Illuminate\Support\Facades\Log; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -18,6 +19,7 @@ use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; #[CoversClass(WebhookSubscribeCommand::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Api::class)] #[UsesClass(Result::class)] final class WebhookSubscribeCommandTest extends TestCase diff --git a/tests/Laravel/Commands/WebhookUnsubscribeCommandTest.php b/tests/Laravel/Commands/WebhookUnsubscribeCommandTest.php index 72e4d72..f304310 100644 --- a/tests/Laravel/Commands/WebhookUnsubscribeCommandTest.php +++ b/tests/Laravel/Commands/WebhookUnsubscribeCommandTest.php @@ -8,6 +8,7 @@ use BushlanovDev\MaxMessengerBot\Api; use BushlanovDev\MaxMessengerBot\Laravel\Commands\WebhookUnsubscribeCommand; use BushlanovDev\MaxMessengerBot\Models\Result; use Illuminate\Support\Facades\Log; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -16,6 +17,7 @@ use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; #[CoversClass(WebhookUnsubscribeCommand::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Api::class)] #[UsesClass(Result::class)] final class WebhookUnsubscribeCommandTest extends TestCase diff --git a/tests/Laravel/MaxBotManagerTest.php b/tests/Laravel/MaxBotManagerTest.php index e9c3a22..88f6396 100644 --- a/tests/Laravel/MaxBotManagerTest.php +++ b/tests/Laravel/MaxBotManagerTest.php @@ -20,6 +20,7 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Config\Repository; use Illuminate\Http\Request; use Illuminate\Support\Facades\Facade; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; @@ -28,6 +29,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; #[CoversClass(MaxBotManager::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Message::class)] #[UsesClass(MessageBody::class)] #[UsesClass(Recipient::class)] diff --git a/tests/Laravel/MaxBotServiceProviderTest.php b/tests/Laravel/MaxBotServiceProviderTest.php index c74107c..5c0562c 100644 --- a/tests/Laravel/MaxBotServiceProviderTest.php +++ b/tests/Laravel/MaxBotServiceProviderTest.php @@ -22,6 +22,7 @@ use InvalidArgumentException; use LogicException; use Orchestra\Testbench\TestCase; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -33,6 +34,7 @@ use Psr\Log\NullLogger; use ReflectionClass; #[CoversClass(MaxBotServiceProvider::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(Api::class)] #[UsesClass(Client::class)] #[UsesClass(UpdateDispatcher::class)] diff --git a/tests/LongPollingHandlerTest.php b/tests/LongPollingHandlerTest.php index 0d6209b..f29758e 100644 --- a/tests/LongPollingHandlerTest.php +++ b/tests/LongPollingHandlerTest.php @@ -16,6 +16,7 @@ use BushlanovDev\MaxMessengerBot\UpdateDispatcher; use Error; use Exception; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -26,6 +27,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; #[CoversClass(LongPollingHandler::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(UpdateDispatcher::class)] #[UsesClass(UpdateList::class)] #[UsesClass(AbstractUpdate::class)] diff --git a/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php b/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php index 2b67ddc..297b447 100644 --- a/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php +++ b/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php @@ -6,7 +6,6 @@ namespace BushlanovDev\MaxMessengerBot\Tests\Models\Attachments\Buttons\Inline; use BushlanovDev\MaxMessengerBot\Enums\InlineButtonType; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\ClipboardButton; -use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\OpenAppButton; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -20,10 +19,9 @@ final class ClipboardButtonTest extends TestCase $button = new ClipboardButton('display', 'copy'); $expectedArray = [ - 'text' => 'display', 'payload' => 'copy', 'type' => InlineButtonType::Clipboard->value, - + 'text' => 'display', ]; $resultArray = $button->toArray(); diff --git a/tests/UpdateDispatcherTest.php b/tests/UpdateDispatcherTest.php index e0c26ad..1506008 100644 --- a/tests/UpdateDispatcherTest.php +++ b/tests/UpdateDispatcherTest.php @@ -14,12 +14,14 @@ use BushlanovDev\MaxMessengerBot\Models\Updates\BotStartedUpdate; use BushlanovDev\MaxMessengerBot\Models\Updates\MessageCreatedUpdate; use BushlanovDev\MaxMessengerBot\Models\UserWithPhoto; use BushlanovDev\MaxMessengerBot\UpdateDispatcher; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(UpdateDispatcher::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(UserWithPhoto::class)] #[UsesClass(BotStartedUpdate::class)] #[UsesClass(Message::class)] diff --git a/tests/WebhookHandlerTest.php b/tests/WebhookHandlerTest.php index b883653..80352e7 100644 --- a/tests/WebhookHandlerTest.php +++ b/tests/WebhookHandlerTest.php @@ -19,6 +19,7 @@ use BushlanovDev\MaxMessengerBot\UpdateDispatcher; use BushlanovDev\MaxMessengerBot\WebhookHandler; use LogicException; use phpmock\phpunit\PHPMock; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -32,6 +33,7 @@ use Psr\Http\Message\StreamInterface; use Psr\Log\LoggerInterface; #[CoversClass(WebhookHandler::class)] +#[AllowMockObjectsWithoutExpectations] #[UsesClass(UpdateDispatcher::class)] #[UsesClass(Message::class)] #[UsesClass(MessageBody::class)]