Skip to content

Commit de13980

Browse files
committed
test for syslogudp configuration
1 parent 870a90a commit de13980

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
@@ -158,7 +158,7 @@
158158
* - [level]: level name or int value, defaults to DEBUG
159159
* - [bubble]: bool, defaults to true
160160
* - [ident]: string, defaults to
161-
* - [rfc]: RFC3164 or RFC5424, defaults to RFC5424
161+
* - [rfc]: SyslogUdpHandler::RFC3164 (0) or SyslogUdpHandler::RFC5424 (1), defaults to SyslogUdpHandler::RFC5424
162162
*
163163
* - swift_mailer:
164164
* - 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;
@@ -406,6 +407,48 @@ public function testWithRedisHandler()
406407
$this->assertEquals('monolog_redis_test', $config['handlers']['redis']['redis']['key_name']);
407408
}
408409

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

0 commit comments

Comments
 (0)