Skip to content

Commit bcdb0eb

Browse files
committed
test for syslogudp configuration
1 parent fd04918 commit bcdb0eb

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
* - [level]: level name or int value, defaults to DEBUG
164164
* - [bubble]: bool, defaults to true
165165
* - [ident]: string, defaults to
166-
* - [rfc]: RFC3164 or RFC5424, defaults to RFC5424
166+
* - [rfc]: SyslogUdpHandler::RFC3164 (0) or SyslogUdpHandler::RFC5424 (1), defaults to SyslogUdpHandler::RFC5424
167167
*
168168
* - swift_mailer:
169169
* - from_email: optional if email_prototype is given

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection;
1313

14+
use Monolog\Handler\SyslogUdpHandler;
1415
use Monolog\Logger;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bundle\MonologBundle\DependencyInjection\Configuration;
@@ -407,6 +408,48 @@ public function testWithRedisHandler()
407408
$this->assertEquals('monolog_redis_test', $config['handlers']['redis']['redis']['key_name']);
408409
}
409410

411+
public function testWithSyslogUdpHandler()
412+
{
413+
$configs = [
414+
[
415+
'handlers' => [
416+
'syslogudp' => [
417+
'type' => 'syslogudp',
418+
'host' => '127.0.0.1',
419+
'port' => 514,
420+
'facility' => 'USER',
421+
'level' => 'ERROR',
422+
'rfc' => SyslogUdpHandler::RFC3164
423+
]
424+
]
425+
]
426+
];
427+
$config = $this->process($configs);
428+
429+
$this->assertEquals('syslogudp', $config['handlers']['syslogudp']['type']);
430+
$this->assertEquals('127.0.0.1', $config['handlers']['syslogudp']['host']);
431+
$this->assertEquals(514, $config['handlers']['syslogudp']['port']);
432+
$this->assertEquals(0, $config['handlers']['syslogudp']['rfc']);
433+
434+
$configs = [
435+
[
436+
'handlers' => [
437+
'syslogudp' => [
438+
'type' => 'syslogudp',
439+
'host' => '127.0.0.1',
440+
'port' => 514,
441+
'facility' => 'USER',
442+
'level' => 'ERROR',
443+
'rfc' => SyslogUdpHandler::RFC5424e
444+
]
445+
]
446+
]
447+
];
448+
449+
$this->expectException(InvalidConfigurationException::class);
450+
$config = $this->process($configs);
451+
}
452+
410453
/**
411454
* @group legacy
412455
*/

0 commit comments

Comments
 (0)