SilentLoggerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSilentLogger() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cakasim\Payone\Sdk\Tests\Log\SilentLogger;
6
7
use Cakasim\Payone\Sdk\Log\SilentLogger\SilentLogger;
8
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase 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 Psr\Log\LoggerInterface;
10
use ReflectionClass;
11
12
/**
13
 * @author Fabian Böttcher <[email protected]>
14
 * @since 0.1.0
15
 */
16
class SilentLoggerTest extends TestCase
17
{
18
    /**
19
     * @testdox The logger is silent
20
     */
21
    public function testSilentLogger(): void
22
    {
23
        $logger = new SilentLogger();
24
        $this->assertInstanceOf(LoggerInterface::class, $logger);
25
26
        // Inspect SilentLogger to be actually silent.
27
        // Check for exactly 3 lines of code.
28
        $class = new ReflectionClass($logger);
29
        $method = $class->getMethod('log');
30
        $this->assertEquals(3, $method->getEndLine() - $method->getStartLine());
31
32
        // Check if the lines of code are silent.
33
        $source = file($class->getFileName());
34
        $this->assertRegExp('~^\s*{\s*$~', $source[$method->getStartLine()]);
35
        $this->assertRegExp('~^\s*//~', $source[$method->getStartLine() + 1]);
36
        $this->assertRegExp('~^\s*}\s*$~', $source[$method->getStartLine() + 2]);
37
    }
38
}
39