Passed
Push — master ( 02ad68...578058 )
by Alex
01:35 queued 13s
created

NullHandlerFactoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 54
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvokeWillReturnConfiguredNullHandlerInstance() 0 7 1
A testImplementsFactoryInterface() 0 5 1
A setUp() 0 3 1
A getInvokeWillReturnConfiguredNullHandlerInstanceData() 0 9 1
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