DisableListenersTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A throwExceptionListener() 0 3 1
A test_disable_class_resolver_listener() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\Framework\ListeningEvents\ClassResolver;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\Gacela;
9
use GacelaTest\Feature\Framework\ListeningEvents\ClassResolver\Module\Facade;
10
use PHPUnit\Framework\Attributes\PreserveGlobalState;
11
use PHPUnit\Framework\TestCase;
12
use RuntimeException;
13
14
final class DisableListenersTest extends TestCase
15
{
16
    #[PreserveGlobalState(false)]
17
    public function test_disable_class_resolver_listener(): void
18
    {
19
        Gacela::bootstrap(__DIR__, function (GacelaConfig $config): void {
20
            $config->disableEventListeners();
21
22
            $config->registerGenericListener(function (): never {
23
                $this->throwExceptionListener();
24
            });
25
        });
26
27
        $facade = new Facade();
28
        $facade->doString();
29
30
        $facade = new Facade();
31
        $facade->doString();
32
33
        $this->expectNotToPerformAssertions();
34
    }
35
36
    public function throwExceptionListener(): never
37
    {
38
        throw new RuntimeException('This should never be called');
39
    }
40
}
41