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

Telegram Handler: support additional API parameters (#1451)

This commit is contained in:
Pascal Sommer
2020-05-22 08:44:02 +02:00
committed by GitHub
parent de87dad98f
commit 7a801dd041
2 changed files with 83 additions and 3 deletions

View File

@@ -35,9 +35,15 @@ class TelegramBotHandlerTest extends TestCase
* @param string $apiKey
* @param string $channel
*/
private function createHandler(string $apiKey = 'testKey', string $channel = 'testChannel'): void
private function createHandler(
string $apiKey = 'testKey',
string $channel = 'testChannel',
string $parseMode = 'Markdown',
bool $disableWebPagePreview = false,
bool $disableNotification = true
): void
{
$constructorArgs = [$apiKey, $channel, Logger::DEBUG, true];
$constructorArgs = [$apiKey, $channel, Logger::DEBUG, true, $parseMode, $disableWebPagePreview, $disableNotification];
$this->handler = $this->getMockBuilder(TelegramBotHandler::class)
->setConstructorArgs($constructorArgs)
@@ -47,4 +53,18 @@ class TelegramBotHandlerTest extends TestCase
$this->handler->expects($this->atLeast(1))
->method('send');
}
public function testSetInvalidParseMode(): void
{
$this->expectException(\InvalidArgumentException::class);
$handler = new TelegramBotHandler('testKey', 'testChannel');
$handler->setParseMode('invalid parse mode');
}
public function testSetParseMode(): void
{
$handler = new TelegramBotHandler('testKey', 'testChannel');
$handler->setParseMode('HTML');
}
}