TelegramBotHandlerTest.php 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Monolog\Handler;
  3. use Monolog\Logger;
  4. use Monolog\Test\TestCase;
  5. /**
  6. * @author Mazur Alexandr <alexandrmazur96@gmail.com>
  7. * @link https://core.telegram.org/bots/api
  8. */
  9. class TelegramBotHandlerTest extends TestCase
  10. {
  11. /**
  12. * @var TelegramBotHandler
  13. */
  14. private $handler;
  15. public function testSendTelegramRequest(): void
  16. {
  17. $this->createHandler();
  18. $this->handler->handle($this->getRecord());
  19. }
  20. /**
  21. * @param string $apiKey
  22. * @param string $channel
  23. */
  24. private function createHandler(string $apiKey = 'testKey', string $channel = 'testChannel'): void
  25. {
  26. $constructorArgs = [$apiKey, $channel, Logger::DEBUG, true];
  27. $this->handler = $this->getMockBuilder(TelegramBotHandler::class)
  28. ->setConstructorArgs($constructorArgs)
  29. ->setMethods(['send'])
  30. ->getMock();
  31. $this->handler->expects($this->atLeast(1))
  32. ->method('send');
  33. }
  34. }