Hearing updates
Overview
After you have configured your first testcase, to test your handlers you have to define which update it will process. To do that, the framework gives you some methods to automatically generate incoming updates.
Example
We assume that the $this->bot is loaded as mentioned on the Introduction page.
- Test
- Triggered Handler
$this->bot
->hearText('/foo')
->reply();
$bot->onCommand('foo', function (Nutgram $bot) {
// this handler will be called
});
Available Methods
hearUpdate
The hearUpdate hears an outcoming Update object.
->hearUpdate(new Update());
hearUpdateType
The hearUpdateType hears an outcoming Update subtype array.
The partialAttributes and fillNullableFields parameters are optionals.
->hearUpdateType(UpdateTypes::MESSAGE, partialAttributes: ['text' => '/foo'], fillNullableFields: false);
hearMessage
The hearMessage hears an outcoming Message array.
->hearMessage(['text' => 'foo']);
hearText
The hearText hears an outcoming Message text.
->hearText('foo');
hearCallbackQueryData
The hearCallbackQueryData hears an outcoming CallbackQuery data.
->hearCallbackQueryData('baz');