Passed
Push — trunk ( 36db4a...0fa3f8 )
by Christian
16:05 queued 14s
created

AssertingEventDispatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Test\Stub\EventDispatcher;
4
5
use PHPUnit\Framework\TestCase;
6
use Shopware\Core\Framework\Test\TestCaseHelper\CallableClass;
7
use Symfony\Component\EventDispatcher\EventDispatcher;
8
9
class AssertingEventDispatcher extends EventDispatcher
10
{
11
    /**
12
     * @param array<string, int> $assertions
13
     */
14
    public function __construct(TestCase $test, array $assertions)
15
    {
16
        foreach ($assertions as $event => $count) {
17
            $listener = $test->getMockBuilder(CallableClass::class)->getMock();
18
            $listener
19
                ->expects(TestCase::exactly($count))
20
                ->method('__invoke');
21
22
            $this->addListener($event, $listener);
23
        }
24
    }
25
}
26