1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-13 00:24:10 +02:00

Add telegram bot handler.

This commit is contained in:
Alexandr Mazur
2019-06-25 20:19:02 +03:00
parent c37ff2a96f
commit 1284105074
2 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\Test\TestCase;
/**
* @author Mazur Alexandr <alexandrmazur96@gmail.com>
* @link https://core.telegram.org/bots/api
*/
class TelegramBotHandlerTest extends TestCase
{
/**
* @var TelegramBotHandler
*/
private $handler;
public function testSendTelegramRequest(): void
{
$this->createHandler();
$this->handler->handle($this->getRecord());
}
/**
* @param string $apiKey
* @param string $channel
*/
private function createHandler(string $apiKey = 'testKey', string $channel = 'testChannel'): void
{
$constructorArgs = [$apiKey, $channel, Logger::DEBUG, true];
$this->handler = $this->getMockBuilder(TelegramBotHandler::class)
->setConstructorArgs($constructorArgs)
->setMethods(['send'])
->getMock();
$this->handler->expects($this->atLeast(1))
->method('send')
->willReturn(null);
}
}