Skip to content

Commit

Permalink
test for syslogudp configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gwinn committed Feb 1, 2021
1 parent 870a90a commit de13980
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
* - [ident]: string, defaults to
* - [rfc]: RFC3164 or RFC5424, defaults to RFC5424
* - [rfc]: SyslogUdpHandler::RFC3164 (0) or SyslogUdpHandler::RFC5424 (1), defaults to SyslogUdpHandler::RFC5424
*
* - swift_mailer:
* - from_email: optional if email_prototype is given
Expand Down
43 changes: 43 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection;

use Monolog\Handler\SyslogUdpHandler;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\MonologBundle\DependencyInjection\Configuration;
Expand Down Expand Up @@ -406,6 +407,48 @@ public function testWithRedisHandler()
$this->assertEquals('monolog_redis_test', $config['handlers']['redis']['redis']['key_name']);
}

public function testWithSyslogUdpHandler()
{
$configs = [
[
'handlers' => [
'syslogudp' => [
'type' => 'syslogudp',
'host' => '127.0.0.1',
'port' => 514,
'facility' => 'USER',
'level' => 'ERROR',
'rfc' => SyslogUdpHandler::RFC3164
]
]
]
];
$config = $this->process($configs);

$this->assertEquals('syslogudp', $config['handlers']['syslogudp']['type']);
$this->assertEquals('127.0.0.1', $config['handlers']['syslogudp']['host']);
$this->assertEquals(514, $config['handlers']['syslogudp']['port']);
$this->assertEquals(0, $config['handlers']['syslogudp']['rfc']);

$configs = [
[
'handlers' => [
'syslogudp' => [
'type' => 'syslogudp',
'host' => '127.0.0.1',
'port' => 514,
'facility' => 'USER',
'level' => 'ERROR',
'rfc' => SyslogUdpHandler::RFC5424e
]
]
]
];

$this->expectException(InvalidConfigurationException::class);
$config = $this->process($configs);
}

/**
* Processes an array of configurations and returns a compiled version.
*
Expand Down

0 comments on commit de13980

Please sign in to comment.