public function its_listener_can_accept_a_callable_as_a_matcher(BotInterface $bot, CommandInterface $command, Packet $packet) { $packet->offsetGet('command')->willReturn($command); $packet->offsetSet('output', null)->shouldBeCalled(); $packet->stopPropagation()->shouldBeCalled(); $bot->execute($command)->shouldBeCalled(); $listener = $this->getListener($bot, function ($command) { return true; }); $listener($packet); }
public function it_encodes_the_output(FormatterInterface $formatter, Packet $packet, Reply $reply) { $unencoded = '<foo!> <#C01010|botgarage>'; $encoded = '<foo!> <#C01010|botgarage>'; $packet->offsetExists('output')->willReturn(true); $packet->offsetGet('output')->willReturn($reply); $reply->offsetExists('text')->willReturn(true); $reply->offsetGet('text')->willReturn($unencoded); $formatter->format($unencoded)->willReturn($encoded); $reply->offsetSet('text', $encoded)->shouldBeCalled(); $this->onAfterExecute($packet); }