diff --git a/src/Testing/BotManTester.php b/src/Testing/BotManTester.php index 7c685da..5a00ef0 100644 --- a/src/Testing/BotManTester.php +++ b/src/Testing/BotManTester.php @@ -92,6 +92,17 @@ public function setUser($user_info) return $this; } + /** + * @param string $channel + * @return $this + */ + public function setChannel($channel) + { + $this->channel = $channel ?? $this->channel; + + return $this; + } + /** * @param IncomingMessage $message * @return $this diff --git a/tests/BotManTesterTest.php b/tests/BotManTesterTest.php index cf3b391..d436f80 100644 --- a/tests/BotManTesterTest.php +++ b/tests/BotManTesterTest.php @@ -95,6 +95,21 @@ public function it_can_fake_user_information() $this->tester->assertReply('User: marcelpociot'); } + /** @test */ + public function it_can_fake_channel() + { + $this->botman->hears('message', function ($bot) { + $bot->reply('Recipient: '.$bot->getMessage()->getRecipient()); + }); + + $this->tester->setChannel(123); + $this->tester->receives('message'); + $messages = $this->tester->getMessages(); + + $this->assertCount(1, $messages); + $this->tester->assertReply('Recipient: 123'); + } + /** @test */ public function it_can_assert_replies() {