Failed Conditions
Pull Request — master (#11)
by Adrien
15:48 queued 12:33
created

tests/Log/LoggerFactoryTest.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Log;
6
7
use Ecodev\Felix\Log\LoggerFactory;
8
use Ecodev\Felix\Log\Writer\Db;
1 ignored issue
show
The type Ecodev\Felix\Log\Writer\Db was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Ecodev\Felix\Log\Writer\Mail;
10
use Laminas\Log\Logger;
11
use Laminas\ServiceManager\ServiceManager;
12
use PHPUnit\Framework\TestCase;
13
14
class LoggerFactoryTest extends TestCase
15
{
16
    protected function setUp(): void
17
    {
18
        @mkdir('logs');
19
    }
20
21
    protected function tearDown(): void
22
    {
23
        Logger::unregisterErrorHandler();
24
        Logger::unregisterExceptionHandler();
25
        shell_exec('rm -rf logs/');
26
    }
27
28
    public function testWithMailWriter(): void
29
    {
30
        $container = new ServiceManager([
31
            'factories' => [
32
                Db::class => fn () => self::createMock(Db::class),
33
                Mail::class => fn () => self::createMock(Mail::class),
34
            ],
35
        ]);
36
37
        $factory = new LoggerFactory();
38
        $actual = $factory($container, '');
39
        self::assertInstanceOf(Logger::class, $actual);
40
        self::assertCount(3, $actual->getWriters());
41
    }
42
43
    public function testWithoutMailWriter(): void
44
    {
45
        $container = new ServiceManager([
46
            'factories' => [
47
                Db::class => fn () => self::createMock(Db::class),
48
                Mail::class => fn () => null,
49
            ],
50
        ]);
51
52
        $factory = new LoggerFactory();
53
        $actual = $factory($container, '');
54
        self::assertInstanceOf(Logger::class, $actual);
55
        self::assertCount(2, $actual->getWriters());
56
    }
57
}
58