-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogManagerTest.php
More file actions
43 lines (36 loc) · 1.24 KB
/
LogManagerTest.php
File metadata and controls
43 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace App\Tests\Manager;
use App\Manager\LogManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
final class LogManagerTest extends KernelTestCase
{
private LogManager $logManager;
protected function setUp(): void
{
self::bootKernel();
$this->logManager = self::getContainer()->get('test.'.LogManager::class);
}
public function testCriticalLog(): void
{
$this->assertEquals(LogManager::SUCCESS, $this->logManager->logException(new \Exception('Test exception.')));
}
public function testLogCallable(): void
{
/** @var LoggerInterface|MockObject */
$logger = $this->createMock(LoggerInterface::class);
$logger
->expects($this->once())
->method('log')
->with(
$this->equalTo(LogLevel::EMERGENCY),
$this->stringEndsWith(__FUNCTION__),
$this->logicalAnd($this->arrayHasKey('exception'), $this->arrayHasKey('trace'))
)
;
$logManager = new LogManager($logger);
$logManager->logException(new \Exception('Test exception.'), LogLevel::EMERGENCY);
}
}