getInvokeWillReturnConfiguredNullHandlerInstanceData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
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
final class NullHandlerFactoryTest extends TestCase
21
{
22
    /**
23
     * @var ContainerInterface&MockObject
24
     */
25
    private ContainerInterface $container;
26
27
    public function setUp(): void
28
    {
29
        $this->container = $this->createMock(ContainerInterface::class);
30
    }
31
32
    /**
33
     * Assert that the factory implements FactoryInterface
34
     */
35
    public function testImplementsFactoryInterface(): void
36
    {
37
        $factory = new NullHandlerFactory();
38
39
        $this->assertInstanceOf(FactoryInterface::class, $factory);
40
    }
41
42
    /**
43
     * @dataProvider getInvokeWillReturnConfiguredNullHandlerInstanceData
44
     *
45
     * @param array<mixed> $options
46
     *
47
     * @throws ServiceNotCreatedException
48
     * @throws ContainerExceptionInterface
49
     */
50
    public function testInvokeWillReturnConfiguredNullHandlerInstance(array $options): void
51
    {
52
        $factory = new NullHandlerFactory();
53
54
        $handler = $factory($this->container, NullHandler::class, $options);
55
56
        $this->assertInstanceOf(NullHandler::class, $handler);
57
    }
58
59
    /**
60
     * @return array<mixed>
61
     */
62
    public function getInvokeWillReturnConfiguredNullHandlerInstanceData(): array
63
    {
64
        return [
65
            [
66
                []
67
            ],
68
            [
69
                [
70
                    'level' => Logger::CRITICAL,
71
                ]
72
            ]
73
        ];
74
    }
75
}
76