3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Core\Logger;
24 use Friendica\Core\Logger\Exception\LogLevelException;
25 use Friendica\Core\Logger\Type\SyslogLogger;
28 class SyslogLoggerTest extends AbstractLoggerTest
31 * @var SyslogLoggerWrapper
35 protected function setUp(): void
39 $this->introspection->shouldReceive('addClasses')->with([SyslogLogger::class]);
40 $this->config->shouldReceive('get')->with('system', 'syslog_flags')->andReturn(SyslogLogger::DEFAULT_FLAGS)
42 $this->config->shouldReceive('get')->with('system', 'syslog_facility')
43 ->andReturn(SyslogLogger::DEFAULT_FACILITY)->once();
49 protected function getContent()
51 return $this->logger->getContent();
57 protected function getInstance($level = LogLevel::DEBUG)
59 $this->config->shouldReceive('get')->with('system', 'loglevel')->andReturn($level);
61 $loggerFactory = new SyslogLoggerFactoryWrapper($this->introspection, 'test');
62 $this->logger = $loggerFactory->create($this->config);
69 * Test when the minimum level is not valid
71 public function testWrongMinimumLevel()
73 $this->expectException(LogLevelException::class);
74 $this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
76 $logger = $this->getInstance('NOPE');
80 * Test when the minimum level is not valid
82 public function testWrongLogLevel()
84 $this->expectException(LogLevelException::class);
85 $this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
87 $logger = $this->getInstance();
89 $logger->log('NOPE', 'a test');
93 * Test the close() method
94 * @doesNotPerformAssertions
96 public function testClose()
98 $logger = $this->getInstance();
99 $logger->emergency('test');
102 $logger->emergency('test');