Completed
Push — ezp-30616 ( 8e069f...7bf8e8 )
by
unknown
23:24 queued 01:36
created

AbstractServiceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEventDispatcher() 0 11 1
A getListenersStack() 0 10 2
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Event\Tests;
8
9
use eZ\Publish\Core\Event\AfterEvent;
10
use eZ\Publish\Core\Event\BeforeEvent;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
13
use Symfony\Component\EventDispatcher\EventDispatcher;
14
use Symfony\Component\Stopwatch\Stopwatch;
15
16
abstract class AbstractServiceTest extends TestCase
17
{
18
    public function getEventDispatcher(string $beforeEventName, string $eventName): TraceableEventDispatcher
19
    {
20
        $eventDispatcher = new EventDispatcher();
21
        $eventDispatcher->addListener($beforeEventName, function (BeforeEvent $event) {});
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
        $eventDispatcher->addListener($eventName, function (AfterEvent $event) {});
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
24
        return new TraceableEventDispatcher(
25
            $eventDispatcher,
26
            new Stopwatch()
27
        );
28
    }
29
30
    public function getListenersStack(array $listeners): array
31
    {
32
        $stack = [];
33
34
        foreach ($listeners as $listener) {
35
            $stack[] = [$listener['event'], $listener['priority']];
36
        }
37
38
        return $stack;
39
    }
40
}
41