DEF STUDIO srl

Need help with Laravel and web development?

Hire one of our experts for your projects.

We build tailored products, websites and platforms — with care for UX, performance and maintainability.

Booking open for Q4 — limited slots

You are seeing the documentation for version 1, but the last version for this package is v1. Click here to go to the last version.

Fake messages assertions

The ::fake() facade helper enables a number of assertions for checking its activity

assertSent

asserts that a message was sent to Telegram with the given text

//will check that the sent text is exactly 'hello'
Telegraph::assertSent('hello');

//will check that the sent text contains 'hello'
Telegraph::assertSent('hello', false);

assertNothingSent

asserts that no messages where sent to Telegram

Telegraph::assertNothingSent();

assertSentData

asserts that the given data was sent to a Telegram API endpoint

Telegraph::assertSentData(
    DefStudio\Telegraph\Telegraph::ENDPOINT_MESSAGE, 
    ['text' => 'foo bar baz']
);

Telegraph::assertSentData(
    DefStudio\Telegraph\Telegraph::ENDPOINT_REPLACE_KEYBOARD,
    [
        'chat_id' => -546874,
        'message_id' => 42,
        'reply_markup' => null,
    ]
);

For an end-to-end webhook command example, see the first-bot testing path: Build your first Telegram bot with Telegraph. It combines Telegraph::fake(), Telegraph::assertSent(), and Telegraph::assertSentData() to verify that /start answers in the expected first chat.

assertSentFiles

asserts that the given files were sent to a Telegram API endpoint

Telegraph::assertSentFiles(\DefStudio\Telegraph\Telegraph::ENDPOINT_SEND_DOCUMENT, [
   'document' => new Attachment(Storage::path('test.txt'), 'test.txt'),
]);

assertSentEditMedia

asserts that the given data was sent to a Telegram API endpoint

Telegraph::assertSentEditMedia('mediaType', Storage::path('photo.jpg'));

assertStoredFile

asserts that the given incoming file was stored

Telegraph::assertStoredFile($fileId);

assertRegisteredWebhook

asserts that a webhook register request has been sent

Telegraph::assertRegisteredWebhook();

assertRequestedWebhookDebugInfo

asserts that a webhook debug info request has been sent

Telegraph::assertRequestedWebhookDebugInfo();

assertRepliedWebhook

asserts that a webhook reply has been sent with the given text

Telegraph::assertRepliedWebhook('task completed');
Suggest a change
Last updated 29 May 2026