Passed
Push — master ( be5511...23299f )
by butschster
09:23 queued 01:59
created

LoggerTest.php$0 ➔ has()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Tests\Monolog;
6
7
use Mockery as m;
8
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
9
use Monolog\Logger;
10
use PHPUnit\Framework\TestCase;
11
use Psr\Log\LoggerInterface;
12
use Spiral\Boot\BootloadManager;
13
use Spiral\Boot\Finalizer;
14
use Spiral\Boot\FinalizerInterface;
15
use Spiral\Config\ConfigManager;
16
use Spiral\Config\ConfiguratorInterface;
17
use Spiral\Config\LoaderInterface;
18
use Spiral\Core\Container;
19
use Spiral\Monolog\Bootloader\MonologBootloader;
20
use Spiral\Monolog\LogFactory;
21
22
class LoggerTest extends TestCase
23
{
24
    use MockeryPHPUnitIntegration;
25
26
    public function testLoggerShouldBeReset()
27
    {
28
        $container = new Container();
29
        $container->bind(ConfiguratorInterface::class, new ConfigManager(
0 ignored issues
show
Bug introduced by
new Spiral\Config\ConfigManager(new ClassNode()) of type Spiral\Config\ConfigManager is incompatible with the type array|callable|string expected by parameter $resolver of Spiral\Core\Container::bind(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
        $container->bind(ConfiguratorInterface::class, /** @scrutinizer ignore-type */ new ConfigManager(
Loading history...
30
            new class() implements LoaderInterface {
31
                public function has(string $section): bool
32
                {
33
                    return false;
34
                }
35
36
                public function load(string $section): array
37
                {
38
                    return [];
39
                }
40
            }
41
        ));
42
43
        $container->bind(FinalizerInterface::class, $finalizer = new Finalizer());
0 ignored issues
show
Bug introduced by
$finalizer = new Spiral\Boot\Finalizer() of type Spiral\Boot\Finalizer is incompatible with the type array|callable|string expected by parameter $resolver of Spiral\Core\Container::bind(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        $container->bind(FinalizerInterface::class, /** @scrutinizer ignore-type */ $finalizer = new Finalizer());
Loading history...
44
        $container->bind(LogFactory::class, $injector = m::mock(Container\InjectorInterface::class));
0 ignored issues
show
Bug introduced by
$injector = Mockery::moc...jectorInterface::class) of type Mockery\LegacyMockInterface|Mockery\MockInterface is incompatible with the type array|callable|string expected by parameter $resolver of Spiral\Core\Container::bind(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

44
        $container->bind(LogFactory::class, /** @scrutinizer ignore-type */ $injector = m::mock(Container\InjectorInterface::class));
Loading history...
45
46
        $logger = m::mock(Logger::class);
47
        $logger->shouldReceive('reset')->once();
48
49
        $injector->shouldReceive('createInjection')->once()->andReturn($logger);
50
51
        $container->get(BootloadManager::class)->bootload([MonologBootloader::class]);
52
        $container->get(LoggerInterface::class);
53
54
        $finalizer->finalize();
55
    }
56
}
57