eventDispatcherAwareInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Event;
6
7
use PHPUnit\Framework\TestCase;
8
9
class EventDispatcherAwarenessTest extends TestCase
10
{
11
    /**
12
     * @test
13
     */
14 View Code Duplication
    public function using_a_event_dispatcher(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
    {
16
        $instance = $this->eventDispatcherAwareInstance();
17
        $dispatcher = new EventDispatcher();
18
        $instance->useEventDispatcher($dispatcher);
19
20
        $this->assertSame($dispatcher, $instance->eventDispatcher());
21
    }
22
23
    /**
24
     * @test
25
     */
26 View Code Duplication
    public function when_no_dispatcher_is_provided_a_dispatcher_is_created(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $instance = $this->eventDispatcherAwareInstance();
29
30
        $eventDispatcher = $instance->eventDispatcher();
31
        $this->assertInstanceOf(EventDispatcher::class, $eventDispatcher);
32
        $this->assertSame($eventDispatcher, $instance->eventDispatcher());
33
    }
34
35
    private function eventDispatcherAwareInstance(): EventDispatcherAware
36
    {
37
        return new class() implements EventDispatcherAware {
38
            use EventDispatcherAwareBehavior;
39
        };
40
    }
41
}
42