Added channel setter for tests
Currently, there is only one way to set recipient (channel) in tests by instantiating the IncomingMessage class:
$incoming1 = new IncomingMessage('hi', $sender, $recipient, ['foo' => 'bar']);
$incoming2 = new IncomingMessage('good', $sender, $recipient, ['foo' => 'bar']);
$this->bot
->setUser($sender)
->receivesRaw($incoming1)
->assertQuestion('How are you?')
->receivesRaw($incoming2);
This PR adds an ability to make it easier through a setChannel setter:
$this->bot
->setUser($sender)
->setChannel($channel)
->receives('hi', ['foo' => 'bar'])
->assertQuestion('How are you?')
->receives('good', ['foo' => 'bar']);
It's really useful in conversations. Otherwise, you should instantiate IncomingMessage for every message in a conversation.
Partially solves this issue https://github.com/botman/botman/issues/1218
Codecov Report
Base: 43.35% // Head: 43.88% // Increases project coverage by +0.53% :tada:
Coverage data is based on head (
a454ec0) compared to base (1b6cf1b). Patch coverage: 100.00% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #51 +/- ##
============================================
+ Coverage 43.35% 43.88% +0.53%
- Complexity 75 76 +1
============================================
Files 11 11
Lines 316 319 +3
============================================
+ Hits 137 140 +3
Misses 179 179
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/Testing/BotManTester.php | 95.62% <100.00%> (+0.09%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@crynobone @mpociot any chances to get this merged?
@christophrumpel can this tiny fix be merged?