ErrorLogHandlerFactoryTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
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\ErrorLogHandlerFactory;
9
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
10
use Monolog\Handler\ErrorLogHandler;
11
use Monolog\Logger;
12
use PHPUnit\Framework\MockObject\MockObject;
13
use PHPUnit\Framework\TestCase;
14
use Psr\Container\ContainerInterface;
15
16
/**
17
 * @covers \Arp\LaminasMonolog\Factory\Handler\ErrorLogHandlerFactory
18
 */
19
final class ErrorLogHandlerFactoryTest extends TestCase
20
{
21
    /**
22
     * @var ContainerInterface&MockObject
23
     */
24
    private ContainerInterface $container;
25
26
    public function setUp(): void
27
    {
28
        $this->container = $this->createMock(ContainerInterface::class);
29
    }
30
31
    /**
32
     * Assert that the factory implements FactoryInterface
33
     */
34
    public function testImplementsFactoryInterface(): void
35
    {
36
        $factory = new ErrorLogHandlerFactory();
37
38
        $this->assertInstanceOf(FactoryInterface::class, $factory);
39
    }
40
41
    /**
42
     * Assert that calls to __invoke() will return a configured ErrorLogHandler instance
43
     *
44
     * @throws ServiceNotCreatedException
45
     */
46
    public function testInvokeWillReturnValidErrorLogHandler(): void
47
    {
48
        $factory = new ErrorLogHandlerFactory();
49
50
        $options = [
51
            'level' => Logger::DEBUG,
52
        ];
53
54
        $this->assertInstanceOf(
55
            ErrorLogHandler::class,
56
            $factory($this->container, ErrorLogHandler::class, $options)
57
        );
58
    }
59
}
60