Skip to content

Commit 643c61c

Browse files
committed
Add tests for system_name config key
1 parent 7854458 commit 643c61c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/GelfLoggerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,32 @@ public function it_should_not_have_any_processor_if_the_config_does_not_have_pro
5858

5959
$handler->popProcessor();
6060
}
61+
62+
/** @test */
63+
public function it_should_set_system_name_to_current_hostname_if_system_name_is_null(): void
64+
{
65+
$this->app['config']->set('logging.channels.gelf', [
66+
'system_name' => null,
67+
'driver' => 'custom',
68+
'via' => GelfLoggerFactory::class
69+
]);
70+
71+
$logger = Log::channel('gelf');
72+
73+
$this->assertAttributeEquals(gethostname(), 'systemName', $logger->getHandlers()[0]->getFormatter());
74+
}
75+
76+
/** @test */
77+
public function it_should_set_system_name_to_custom_value_if_system_name_config_is_provided(): void
78+
{
79+
$this->app['config']->set('logging.channels.gelf', [
80+
'system_name' => 'my-system-name',
81+
'driver' => 'custom',
82+
'via' => GelfLoggerFactory::class
83+
]);
84+
85+
$logger = Log::channel('gelf');
86+
87+
$this->assertAttributeEquals('my-system-name', 'systemName', $logger->getHandlers()[0]->getFormatter());
88+
}
6189
}

0 commit comments

Comments
 (0)