Completed
Push — master ( 6e0bb5...dae7dc )
by GBProd
04:09
created

DispatcherTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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