Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to simulate getMessage() response in tests? #1218

Open
chimit opened this issue Nov 8, 2020 · 1 comment
Open

How to simulate getMessage() response in tests? #1218

chimit opened this issue Nov 8, 2020 · 1 comment
Labels

Comments

@chimit
Copy link

chimit commented Nov 8, 2020

  • BotMan Version: 2.6.1
  • PHP Version: 7.4
  • Messaging Service(s): Telegram
  • Cache Driver: file

Description:

There is a test helper setUser(), but there is no analog for setMessage(). I'm using the following data from messages in my code and need to simulate them in tests:

$bot->getMessage()->getSender()
$bot->getMessage()->getRecipient()
$bot->getMessage()->getPayload()

I'm using the Telegram driver.

@chimit
Copy link
Author

chimit commented Nov 16, 2020

I found only one way to simulate these values by using raw objects:

/**
 * IncomingMessage constructor
 *
 * @param string $message
 * @param string $sender
 * @param string $recipient
 * @param array $payload
 */
$incoming = new IncomingMessage('hello', '123', '321', [
    'chat' => [
        'type' => 'private',
    ]
]);

$this->bot
    ->receivesRaw($incoming);

As a temporary solution, it works, but I hope Botman will get it improved later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants