DispatcherTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 6 1
A testDispatchEvent() 0 20 1
1
<?php
2
3
namespace Tests\GBProd\DomainEventBundle\Dispatcher;
4
5
use GBProd\DomainEventBundle\Event\Dispatcher;
6
use GBProd\DomainEvent\DomainEvent;
7
use GBProd\DomainEvent\EventProvider;
8
use GBProd\DomainEvent\EventProviderTrait;
9
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
10
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
11
12
/**
13
 * Tests for Dispatcher
14
 * 
15
 * @author gbprod <[email protected]>
16
 */
17
class DispatcherTest extends \PHPUnit_Framework_TestCase implements EventProvider
18
{
19
    use EventProviderTrait;
20
    
21
    public function testConstruct()
22
    {
23
        new Dispatcher(
24
            $this->getMock(EventDispatcherInterface::class)
25
        );
26
    }
27
    
28
    public function testDispatchEvent()
29
    {
30
        $event = $this->getMock('GBProd\DomainEvent\DomainEvent');
31
        $this->raise($event);
32
        
33
        $symfonyDispatcher = $this->getMock(EventDispatcherInterface::class);
34
        
35
        $symfonyDispatcher
36
            ->expects($this->once())
37
            ->method('dispatch')
38
            ->with(
39
                'DispatcherTest.'.get_class($event),
40
                $this->isInstanceOf(SymfonyEvent::class)
41
            )
42
        ;
43
        
44
        $dispatcher = new Dispatcher($symfonyDispatcher);
45
        
46
        $dispatcher->dispatch($this);
47
    }
48
}