Passed
Pull Request — master (#2)
by Wilmer
02:46 queued 01:33
created

TestCase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 2
b 0
f 0
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 3 1
A invokeMethod() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Yiisoft\Profiler\Tests;
5
6
use Psr\Log\LoggerInterface;
7
use Yiisoft\Factory\Factory;
8
use Yiisoft\Profiler\Tests\Logger\ArrayLogger;
9
10
abstract class TestCase extends \PHPUnit\Framework\TestCase
11
{
12
    /**
13
     * @var Aliases $aliases
0 ignored issues
show
Bug introduced by
The type Yiisoft\Profiler\Tests\Aliases 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...
14
     */
15
    protected $aliases;
16
17
    /**
18
     * @var ArrayLogger $logger
19
     */
20
    protected $logger;
21
22
    /**
23
     * setUp
24
     *
25
     * @return void
26
     */
27
    protected function setUp(): void
28
    {
29
        parent::setUp();
30
31
        $this->factory = new Factory();
0 ignored issues
show
Bug Best Practice introduced by
The property factory does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
32
        $this->logger = new ArrayLogger();
33
    }
34
35
    /**
36
     * tearDown
37
     *
38
     * @return void
39
     */
40
    protected function tearDown(): void
41
    {
42
        parent::tearDown();
43
    }
44
45
    /**
46
     * Invokes a inaccessible method.
47
     *
48
     * @param $object
49
     * @param $method
50
     * @param array $args
51
     * @param bool $revoke whether to make method inaccessible after execution
52
     *
53
     * @return mixed
54
     */
55
    protected function invokeMethod($object, $method, $args = [], $revoke = true)
56
    {
57
        $reflection = new \ReflectionObject($object);
58
        $method = $reflection->getMethod($method);
59
        $method->setAccessible(true);
60
        $result = $method->invokeArgs($object, $args);
61
        if ($revoke) {
62
            $method->setAccessible(false);
63
        }
64
        return $result;
65
    }
66
}
67