1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ArpTest\LaminasMonolog\Factory\Handler; |
6
|
|
|
|
7
|
|
|
use Arp\LaminasFactory\FactoryInterface; |
8
|
|
|
use Arp\LaminasMonolog\Factory\Handler\NullHandlerFactory; |
9
|
|
|
use Laminas\ServiceManager\Exception\ServiceNotCreatedException; |
10
|
|
|
use Monolog\Handler\NullHandler; |
11
|
|
|
use Monolog\Logger; |
12
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use Psr\Container\ContainerExceptionInterface; |
15
|
|
|
use Psr\Container\ContainerInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @covers \Arp\LaminasMonolog\Factory\Handler\NullHandlerFactory |
19
|
|
|
* |
20
|
|
|
* @author Alex Patterson <[email protected]> |
21
|
|
|
* @package Factory\Handler |
22
|
|
|
*/ |
23
|
|
|
final class NullHandlerFactoryTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var ContainerInterface&MockObject |
27
|
|
|
*/ |
28
|
|
|
private ContainerInterface $container; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Prepare the test case dependencies |
32
|
|
|
*/ |
33
|
|
|
public function setUp(): void |
34
|
|
|
{ |
35
|
|
|
$this->container = $this->createMock(ContainerInterface::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Assert that the factory implements FactoryInterface |
40
|
|
|
*/ |
41
|
|
|
public function testImplementsFactoryInterface(): void |
42
|
|
|
{ |
43
|
|
|
$factory = new NullHandlerFactory(); |
44
|
|
|
|
45
|
|
|
$this->assertInstanceOf(FactoryInterface::class, $factory); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @dataProvider getInvokeWillReturnConfiguredNullHandlerInstanceData |
50
|
|
|
* |
51
|
|
|
* @param array<mixed> $options |
52
|
|
|
* |
53
|
|
|
* @throws ServiceNotCreatedException |
54
|
|
|
* @throws ContainerExceptionInterface |
55
|
|
|
*/ |
56
|
|
|
public function testInvokeWillReturnConfiguredNullHandlerInstance(array $options): void |
57
|
|
|
{ |
58
|
|
|
$factory = new NullHandlerFactory(); |
59
|
|
|
|
60
|
|
|
$handler = $factory($this->container, NullHandler::class, $options); |
61
|
|
|
|
62
|
|
|
$this->assertInstanceOf(NullHandler::class, $handler); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return array<mixed> |
67
|
|
|
*/ |
68
|
|
|
public function getInvokeWillReturnConfiguredNullHandlerInstanceData(): array |
69
|
|
|
{ |
70
|
|
|
return [ |
71
|
|
|
[ |
72
|
|
|
[] |
73
|
|
|
], |
74
|
|
|
[ |
75
|
|
|
[ |
76
|
|
|
'level' => Logger::CRITICAL, |
77
|
|
|
] |
78
|
|
|
] |
79
|
|
|
]; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|