Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class TestCase extends \PHPUnit\Framework\TestCase |
||
10 | { |
||
11 | protected ArrayLogger $logger; |
||
12 | |||
13 | protected function setUp(): void |
||
14 | { |
||
15 | parent::setUp(); |
||
16 | |||
17 | $this->logger = new ArrayLogger(); |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * Invokes a inaccessible method. |
||
22 | * |
||
23 | * @param object $object |
||
24 | * @param string $method |
||
25 | * @param array $args |
||
26 | * @param bool $revoke whether to make method inaccessible after execution |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | protected function invokeMethod($object, $method, $args = [], $revoke = true) |
||
31 | { |
||
32 | $reflection = new \ReflectionObject($object); |
||
33 | $method = $reflection->getMethod($method); |
||
34 | $method->setAccessible(true); |
||
35 | $result = $method->invokeArgs($object, $args); |
||
36 | |||
37 | if ($revoke) { |
||
38 | $method->setAccessible(false); |
||
39 | } |
||
40 | |||
41 | return $result; |
||
42 | } |
||
44 |