TelegramBotHandlerTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\Logger;
  12. use Monolog\Test\TestCase;
  13. /**
  14. * @author Mazur Alexandr <alexandrmazur96@gmail.com>
  15. * @link https://core.telegram.org/bots/api
  16. */
  17. class TelegramBotHandlerTest extends TestCase
  18. {
  19. /**
  20. * @var TelegramBotHandler
  21. */
  22. private $handler;
  23. public function testSendTelegramRequest(): void
  24. {
  25. $this->createHandler();
  26. $this->handler->handle($this->getRecord());
  27. }
  28. /**
  29. * @param string $apiKey
  30. * @param string $channel
  31. */
  32. private function createHandler(string $apiKey = 'testKey', string $channel = 'testChannel'): void
  33. {
  34. $constructorArgs = [$apiKey, $channel, Logger::DEBUG, true];
  35. $this->handler = $this->getMockBuilder(TelegramBotHandler::class)
  36. ->setConstructorArgs($constructorArgs)
  37. ->setMethods(['send'])
  38. ->getMock();
  39. $this->handler->expects($this->atLeast(1))
  40. ->method('send')
  41. ->willReturn(null);
  42. }
  43. }